System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

command to find and tar files

 
Sagar Sirdesai
Trusted Contributor

Re: command to find and tar files

Hi
find /dir -depth -name "back*" -type f -print | xargs tar -cvf back.tar


Thanks

Sagar
Highlighted
Dennis Handly
Acclaimed Contributor

Re: command to find and tar files

>Sagar: find /dir -depth -name "back*" -type f -print | xargs tar -cvf back.tar

As Duncan, Steven and I said, you can't use tar with find, unless you gnu tar or pax.

Your example will continually overwrite back.tar and not in a good way.
Laurent Menase
Honored Contributor

Re: command to find and tar files

are you looking for file starting with string back or file which filename start with back?

my solution was to backup files starting with back, not for which filename start with back.

else it is simply
find . -name back\* | xargs tar cvf mytar
Dennis Handly
Acclaimed Contributor

Re: command to find and tar files

>Laurent: find . -name back\* | xargs tar cvf mytar

How many times do we need to mention you can't use find and HP's tar this way? :-)