Go Back   Technology Questions > Software Questions > Operating System Questions > Linux

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 06-15-2008, 05:00 AM
Philipp Ghirardini
Tablet PC Guest
 
Posts: n/a
tar --remove-files

hi!

I have the following problem:

I want to pack all files in a special directory except some particular
ones and delete them afterwards. The files shall be in the archive
without subdirectories.

I have the following tar command:

tar --remove-files -C /net_tests/tests/dir_one -czf
/net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
--exclude=myzip.tar.gz


Actually it does exactly what I want but it returns 2 and not 0 because
of the following reason:

tar: .: Cannot rmdir: Invalid argument
tar: Error exit delayed from previous errors


I think the problem is that the command is packing the '.' and so it is
trying to remove it what fails of course.
I also creates a subdirectory '.' in the archive. Actually it doesn't
matter because when unpacking the archive that has no effect.

The problem is that I need the return value to check if the action was
successful.

Has anyone an idea?

kind regards

Philipp

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 06-15-2008, 05:00 AM
Xploder HD Movie Player for PS3. Manage, convert and transfer media files between the PC and PS3.
  #2 (permalink)  
Old 06-15-2008, 05:20 AM
J.O. Aho
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

Philipp Ghirardini wrote:
> hi!
>
> I have the following problem:
>
> I want to pack all files in a special directory except some particular
> ones and delete them afterwards. The files shall be in the archive
> without subdirectories.
>
> I have the following tar command:
>
> tar --remove-files -C /net_tests/tests/dir_one -czf
> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
> --exclude=myzip.tar.gz
>
>
> Actually it does exactly what I want but it returns 2 and not 0 because
> of the following reason:
>
> tar: .: Cannot rmdir: Invalid argument
> tar: Error exit delayed from previous errors
>
>
> I think the problem is that the command is packing the '.' and so it is
> trying to remove it what fails of course.


I think the tar is trying to delete dir_one, it could be better you
switch to the directory in question, run the command (without the
paths), think that will result in a 0.


--

//Aho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 06-15-2008, 06:10 AM
Philipp Ghirardini
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

J.O. Aho wrote:
> Philipp Ghirardini wrote:
>> hi!
>>
>> I have the following problem:
>>
>> I want to pack all files in a special directory except some particular
>> ones and delete them afterwards. The files shall be in the archive
>> without subdirectories.
>>
>> I have the following tar command:
>>
>> tar --remove-files -C /net_tests/tests/dir_one -czf
>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>> --exclude=myzip.tar.gz
>>
>>
>> Actually it does exactly what I want but it returns 2 and not 0
>> because of the following reason:
>>
>> tar: .: Cannot rmdir: Invalid argument
>> tar: Error exit delayed from previous errors
>>
>>
>> I think the problem is that the command is packing the '.' and so it
>> is trying to remove it what fails of course.

>
> I think the tar is trying to delete dir_one, it could be better you
> switch to the directory in question, run the command (without the
> paths), think that will result in a 0.
>
>


Thanks for your fast reply.

I think I'm doing that with the command -C.
I jump into the directory '/net_tests/tests/dir_one'
There I perform the packing on all files located '.'.

I now tried to change the directory by hand and perform the following
command:

tar --remove-files -czf myzip.tar.gz . --exclude=file3
--exclude=myzip.tar.gz

but got the same result.

regards Philipp


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 06-15-2008, 07:50 AM
jellybean stonerfish
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:


> I have the following tar command:
>
> tar --remove-files -C /net_tests/tests/dir_one -czf
> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
> --exclude=myzip.tar.gz


> I think the problem is that the command is packing the '.' and so it is
> trying to remove it what fails of course. I also creates a subdirectory
> '.' in the archive. Actually it doesn't matter because when unpacking
> the archive that has no effect.
>
> Philipp


Can you use a * to get all the files rather than a . to get the dir?

stonerfish

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 06-15-2008, 09:30 AM
Philipp Ghirardini
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

jellybean stonerfish wrote:
> On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:
>
>
>> I have the following tar command:
>>
>> tar --remove-files -C /net_tests/tests/dir_one -czf
>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>> --exclude=myzip.tar.gz

>
>> I think the problem is that the command is packing the '.' and so it is
>> trying to remove it what fails of course. I also creates a subdirectory
>> '.' in the archive. Actually it doesn't matter because when unpacking
>> the archive that has no effect.
>>
>> Philipp

>
> Can you use a * to get all the files rather than a . to get the dir?
>
> stonerfish
>

No, I tried that but than I got :


tar: compile.sh: Cannot stat: No such file or directory
tar: test_23s.cpp: Cannot stat: No such file or directory
tar: test_23s_inp.cpp: Cannot stat: No such file or directory
tar: test_9s.cpp: Cannot stat: No such file or directory
tar: test_9s_inp.cpp: Cannot stat: No such file or directory
tar: test_fast.cpp: Cannot stat: No such file or directory
tar: test_fast_inp.cpp: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

Which are the files in the directory where i did the call and not the
files of the directory I want to archive.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #6 (permalink)  
Old 06-15-2008, 09:30 AM
jellybean stonerfish
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

On Sun, 15 Jun 2008 18:50:56 +0200, Philipp Ghirardini wrote:

> jellybean stonerfish wrote:
>> On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:
>>
>>
>>> I have the following tar command:
>>>
>>> tar --remove-files -C /net_tests/tests/dir_one -czf
>>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>>> --exclude=myzip.tar.gz

>>
>>> I think the problem is that the command is packing the '.' and so it
>>> is trying to remove it what fails of course. I also creates a
>>> subdirectory '.' in the archive. Actually it doesn't matter because
>>> when unpacking the archive that has no effect.
>>>
>>> Philipp

>>
>> Can you use a * to get all the files rather than a . to get the dir?
>>
>> stonerfish
>>

> No, I tried that but than I got :


Ok I think I see something.
What dir are you in when running tar? The . means what in your original
post?
Are you in /net_tests/tests/dir_one
if not try (backslashes added)

tar --remove-files -C /net_tests/tests/dir_one -czf \
/net_tests/tests/dir_one/myzip.tar.gz /net_tests/tests/dir_one/* \
--exclude=file3 --exclude=myzip.tar.gz


sf



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 06-15-2008, 10:00 AM
Philipp Ghirardini
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

jellybean stonerfish wrote:
> On Sun, 15 Jun 2008 18:50:56 +0200, Philipp Ghirardini wrote:
>
>> jellybean stonerfish wrote:
>>> On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:
>>>
>>>
>>>> I have the following tar command:
>>>>
>>>> tar --remove-files -C /net_tests/tests/dir_one -czf
>>>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>>>> --exclude=myzip.tar.gz
>>>> I think the problem is that the command is packing the '.' and so it
>>>> is trying to remove it what fails of course. I also creates a
>>>> subdirectory '.' in the archive. Actually it doesn't matter because
>>>> when unpacking the archive that has no effect.
>>>>
>>>> Philipp
>>> Can you use a * to get all the files rather than a . to get the dir?
>>>
>>> stonerfish
>>>

>> No, I tried that but than I got :

>
> Ok I think I see something.
> What dir are you in when running tar? The . means what in your original
> post?
> Are you in /net_tests/tests/dir_one
> if not try (backslashes added)
>
> tar --remove-files -C /net_tests/tests/dir_one -czf \
> /net_tests/tests/dir_one/myzip.tar.gz /net_tests/tests/dir_one/* \
> --exclude=file3 --exclude=myzip.tar.gz
>
>
> sf
>
>
>


Using this command exits with 0 but now i have the problem again that
the archiv consists the whole path (/net_tests/tests/dir_one/...).
replacing this part with ./* doesn't work.

regards Philipp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8 (permalink)  
Old 06-15-2008, 11:50 AM
jellybean stonerfish
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

On Sun, 15 Jun 2008 15:50:08 +0200, Philipp Ghirardini wrote:

On Sun, 15 Jun 2008 15:50:08 +0200, Philipp Ghirardini wrote:

> J.O. Aho wrote:
>> Philipp Ghirardini wrote:
>>> hi!
>>>
>>> I have the following problem:
>>>
>>> I want to pack all files in a special directory except some particular
>>> ones and delete them afterwards. The files shall be in the archive
>>> without subdirectories.
>>>
>>> I have the following tar command:
>>>
>>> tar --remove-files -C /net_tests/tests/dir_one -czf
>>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>>> --exclude=myzip.tar.gz
>>>
>>>
>>> Actually it does exactly what I want but it returns 2 and not 0
>>> because of the following reason:
>>>
>>> tar: .: Cannot rmdir: Invalid argument tar: Error exit delayed from
>>> previous errors
>>>
>>>
>>> I think the problem is that the command is packing the '.' and so it
>>> is trying to remove it what fails of course.

>>
>> I think the tar is trying to delete dir_one, it could be better you
>> switch to the directory in question, run the command (without the
>> paths), think that will result in a 0.
>>
>>
>>

> Thanks for your fast reply.
>
> I think I'm doing that with the command -C. I jump into the directory
> '/net_tests/tests/dir_one' There I perform the packing on all files
> located '.'.
>
> I now tried to change the directory by hand and perform the following
> command:
>
> tar --remove-files -czf myzip.tar.gz . --exclude=file3
> --exclude=myzip.tar.gz
>
> but got the same result.
>
> regards Philipp


Did you do * here when you changed to this directory by hand? It seems
to work for me. Also have you played with --strip or --strip-components?

js@blackbox:~/test$ ls -l
total 12
-rw-r--r-- 1 js js 29 2008-06-15 12:09 apple -rw-r--r-- 1 js js 24
2008-06-15 12:09 banana -rw-r--r-- 1 js js 139 2008-06-15 12:11
test.tar.gz

js@blackbox:~/test$ tar --remove-files -czf test.tar.gz * \
--exclude=banana --exclude=test.tar.gz

js@blackbox:~/test$ ls -l
total 8
-rw-r--r-- 1 js js 24 2008-06-15 12:09 banana -rw-r--r-- 1 js js 139
2008-06-15 12:16 test.tar.gz

js@blackbox:~/test$ tar -f test.tar.gz -t apple

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #9 (permalink)  
Old 06-16-2008, 01:50 PM
FrenKy
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

Philipp Ghirardini wrote:
> jellybean stonerfish wrote:
>> On Sun, 15 Jun 2008 18:50:56 +0200, Philipp Ghirardini wrote:
>>
>>> jellybean stonerfish wrote:
>>>> On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:
>>>>
>>>>
>>>>> I have the following tar command:
>>>>>
>>>>> tar --remove-files -C /net_tests/tests/dir_one -czf
>>>>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>>>>> --exclude=myzip.tar.gz
>>>>> I think the problem is that the command is packing the '.' and so it
>>>>> is trying to remove it what fails of course. I also creates a
>>>>> subdirectory '.' in the archive. Actually it doesn't matter because
>>>>> when unpacking the archive that has no effect.
>>>>>
>>>>> Philipp
>>>> Can you use a * to get all the files rather than a . to get the dir?
>>>>
>>>> stonerfish
>>>>
>>> No, I tried that but than I got :

>>
>> Ok I think I see something.
>> What dir are you in when running tar? The . means what in your
>> original post?
>> Are you in /net_tests/tests/dir_one
>> if not try (backslashes added)
>>
>> tar --remove-files -C /net_tests/tests/dir_one -czf \
>> /net_tests/tests/dir_one/myzip.tar.gz /net_tests/tests/dir_one/* \
>> --exclude=file3 --exclude=myzip.tar.gz
>>
>>
>> sf
>>
>>
>>

>
> Using this command exits with 0 but now i have the problem again that
> the archiv consists the whole path (/net_tests/tests/dir_one/...).
> replacing this part with ./* doesn't work.
>
> regards Philipp


If in bash, you could try with set -x and see if you get something
useful upon invocation of tar.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #10 (permalink)  
Old 06-17-2008, 10:20 AM
noi ance
Tablet PC Guest
 
Posts: n/a
Re: tar --remove-files

On Sun, 15 Jun 2008 19:47:22 +0200, Philipp Ghirardini typed this message:

> jellybean stonerfish wrote:
>> On Sun, 15 Jun 2008 18:50:56 +0200, Philipp Ghirardini wrote:
>>
>>> jellybean stonerfish wrote:
>>>> On Sun, 15 Jun 2008 14:54:11 +0200, Philipp Ghirardini wrote:
>>>>
>>>>
>>>>> I have the following tar command:
>>>>>
>>>>> tar --remove-files -C /net_tests/tests/dir_one -czf
>>>>> /net_tests/tests/dir_one/myzip.tar.gz . --exclude=file3
>>>>> --exclude=myzip.tar.gz
>>>>> I think the problem is that the command is packing the '.' and so it
>>>>> is trying to remove it what fails of course. I also creates a
>>>>> subdirectory '.' in the archive. Actually it doesn't matter because
>>>>> when unpacking the archive that has no effect.
>>>>>
>>>>> Philipp
>>>> Can you use a * to get all the files rather than a . to get the dir?
>>>>
>>>> stonerfish
>>>>
>>> No, I tried that but than I got :

>>
>> Ok I think I see something.
>> What dir are you in when running tar? The . means what in your
>> original post?
>> Are you in /net_tests/tests/dir_one
>> if not try (backslashes added)
>>
>> tar --remove-files -C /net_tests/tests/dir_one -czf \
>> /net_tests/tests/dir_one/myzip.tar.gz /net_tests/tests/dir_one/* \
>> --exclude=file3 --exclude=myzip.tar.gz
>>
>>
>> sf
>>
>>
>>
>>

> Using this command exits with 0 but now i have the problem again that
> the archiv consists the whole path (/net_tests/tests/dir_one/...).
> replacing this part with ./* doesn't work.
>
> regards Philipp


Could it be you're having a problem because you're creating the
myzip.tar.gz in the same folder/dir that you're trying to archive and
remove files?

tar --remove-files -C /net_tests/tests/dir_one -czf \
/tmp/myzip.tar.gz /net_tests/tests/dir_one . \
--exclude=file3



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove sp1 backup files GeraldF Windows Vista 4 03-19-2008 02:40 PM
Remove Tags on MP3 files Frank C Windows XP 0 11-11-2007 09:50 AM
Can't remove old game files. J&D Windows XP 1 07-29-2007 10:30 AM
How to remove files from vista? porkribs Windows Vista 5 03-22-2007 08:15 PM
why doesn't add remove programs completely remove files? tonyjeffs Windows XP 9 02-04-2007 03:45 PM


All times are GMT -8. The time now is 01:36 PM.


2003 - 2008 All Rights Reserved. Technology Questions

SEO by vBSEO 3.1.0