LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2006, 07:59 PM   #1
slackamp
Member
 
Registered: Dec 2005
Distribution: slackware-current
Posts: 86

Rep: Reputation: 16
find and tar


how do i use find with tar? command below tars the files twice. i tried with tar -rvf and same results.

find /etc -type f -name "*.bak" | xargs tar -cvf test.tar
 
Old 10-30-2006, 08:08 PM   #2
smaudlin
Member
 
Registered: Dec 2004
Location: Benicia, CA
Distribution: Fedora 6,5,4 Mandrake 10.1
Posts: 46

Rep: Reputation: 15
what about locate test.tar first run updatedb if you never have then locate xxxx being whatever your looking for
 
Old 10-30-2006, 08:48 PM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Try the following:
Code:
find /etc -type f -name '*.bak' -print0 | tar cvf test.tar --null -T -
Dave

Last edited by ilikejam; 10-30-2006 at 08:50 PM.
 
Old 10-31-2006, 12:46 AM   #4
ebasi
Member
 
Registered: Jul 2004
Distribution: Slackware 13.0
Posts: 49

Rep: Reputation: 15
My way:
Code:
find /etc -type f -name '*.bak' -exec tar cvf test.tar {} \;
-exec is an option of find
Code:
man find
 
Old 10-31-2006, 01:49 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
@ebasi: tar's "c" option creates a new tar archive. Since find's -exec is executed for each file found, I suspect you'll be (re)creating the same test.tar file many times.

A not-so-nice work-around would be:
Code:
tar cvf test.tar dummy_file #creates tar
find /etc -type f -name '*.bak' -exec tar rvf test.tar {} \; #appends all *.bak files to tar
tar --delete -f test.tar dummy_file #removes dummy file again
Note that this work-around won't work for tar archives on tape.

slackamp, you could also try something like:
Code:
find /etc -type f -name '*.bak' > files2tar
tar --files-from=files2tar -v -f test.tar
rm files2tar
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
Where I find driver slmodem-2.9.6.tar.gz ? caneca Linux - Newbie 2 10-25-2005 08:25 AM
where to find a tar-file in a rpm sneezesnoeze Linux - Newbie 1 04-06-2004 11:18 AM
Installed RPM/tar file, cant find out how to run it Craneology Linux - Software 4 03-01-2003 08:10 PM


All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration