1831635 Members
1693 Online
110027 Solutions
New Discussion

Re: "find" command

 
SOLVED
Go to solution
Chet Woods
Frequent Advisor

"find" command

Hi all,
I'm having problems with using the "find" command. What I'm trying to do is find everything older than 520 days, and create a tar file with this data, however what I'm getting is a listing (like it would do when creating a tar file) but, the tar file is only the very last file that is listed. Here's my find statement:
find . -mtime +520 -exec tar xvf /home/rlkeller.tar {} \;

Any help would be greatly appreciated.

Chet
8 REPLIES 8
Kevin Wright
Honored Contributor

Re: "find" command

maybe tar cvf.

use xargs too
find . -mtime +520 |xargs tar cvf tar.ball
Chet Woods
Frequent Advisor

Re: "find" command

yeah, oops I meant tar cvf. xargs, what does that do?
Craig Rants
Honored Contributor

Re: "find" command

I would do it in two parts, but that is just me.

1) find . -mtime +520 -exec ls {} \; > /tmp/tar.sh

2) edit /tmp/tar.sh and put
tar cvf /home/rlkeller.tar /file1 /file2
and so on, make sure you put a \ after each line in the file, you could use sed to do this. Then run /tmp/tar.sh

Also I noticed in you find command that you were using xvf instead of cvf, that may be causing you some problems.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Michael Tully
Honored Contributor
Solution

Re: "find" command

Hi,

Try substituting 'xvf' with 'cvf'

and using xargs it processes the information far better. Using -exec uses one process for each input, xargs uses one for the lot, basically it is more efficient, but one drawback, it it does not find anything that it 'parsed' to it, it will backup everything!

# find . -mtime +520 -exec cvf /tmp/test {} \;
# find . -mtime +520 | xargs tar cvf /dev/test


HTH
-Michael
Anyone for a Mutiny ?
James R. Ferguson
Acclaimed Contributor

Re: "find" command

Hi:

Try this:

# find . -mtime +520 | xargs tar xvf /home/rlkeller.tar

Regards!

...JRF...
Darrell Allen
Honored Contributor

Re: "find" command

Hi Chet,

This will work:
find . -mtime +520 | xargs tar cvf /home/rlkeller.tar

Darrell

"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Darrell Allen
Honored Contributor

Re: "find" command

Dang, always slower than James (and Michael many times also)!

N/A mine, please.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Chet Woods
Frequent Advisor

Re: "find" command

Thanks everyone, this worked:

find . -mtime +520 | xargs tar cvf /home/rlkeller.tar


Thanks again,
Chet