LinuxQuestions.org
Review your favorite Linux distribution.
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 05-08-2007, 01:15 PM   #1
zest n zeal
LQ Newbie
 
Registered: May 2007
Posts: 18

Rep: Reputation: 0
problem with using find and tar together


Hi, what I have been trying to do is tar up all the files that were touched in the last 24 hours into a single file. Seems simple right?

sohpsy211:/respaldo # find /home/am0032/ -mtime 0


found all the files as expected... but as soon as I did this ....

sohpsy211:/respaldo # find /home/am0032/ -mtime 0 | tar zcvf /respaldo/today.tgz -T-

Then the input from the find command was ignored and the entire contents of /home/am0032/ starts to get tarred up.

Any ideas why? Or how to get around this?

Many thanks for any assistance.

Adam
 
Old 05-08-2007, 02:07 PM   #2
Centinul
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 552

Rep: Reputation: 30
try this:

Code:
find /home/am0032/ -mtime 0 -exec tar zcvf /respaldo/today.tgz  \;
This isn't tested so I'm not sure if it will work.

HTH,

Centinul
 
Old 05-08-2007, 02:25 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, and welcome to LQ!

Quote:
Originally Posted by zest n zeal
Hi, what I have been trying to do is tar up all the files that were touched in the last 24 hours into a single file. Seems simple right?

sohpsy211:/respaldo # find /home/am0032/ -mtime 0


found all the files as expected... but as soon as I did this ....

sohpsy211:/respaldo # find /home/am0032/ -mtime 0 | tar zcvf /respaldo/today.tgz -T-

Then the input from the find command was ignored and the entire contents of /home/am0032/ starts to get tarred up.

Any ideas why? Or how to get around this?

Many thanks for any assistance.

Adam
Chances are it is working. But if any file in /home/am0032/
has an mtime of 0, so will /home/am0032; hence it will all
be tarred up. What happens if you add -type f to the find?



Cheers,
Tink
 
Old 05-08-2007, 02:39 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,649

Rep: Reputation: 391Reputation: 391Reputation: 391Reputation: 391
Quote:
Originally Posted by zest n zeal
Hi, what I have been trying to do is tar up all the files that were touched in the last 24 hours into a single file. Seems simple right?

sohpsy211:/respaldo # find /home/am0032/ -mtime 0


found all the files as expected...
Not only files but directories too, including the topmost one as you are missing the "-type f" option.
Quote:
but as soon as I did this ....

sohpsy211:/respaldo # find /home/am0032/ -mtime 0 | tar zcvf /respaldo/today.tgz -T-

Then the input from the find command was ignored and the entire contents of /home/am0032/ starts to get tarred up.
The input wasn't ignored.
Quote:
Any ideas why? Or how to get around this?
If there aren't too much files, you can run this:
Code:
tar czvf /respaldo/today.tgz $(find ~am0032 -type f -mtime 0)
For a more robust solution, that one should work:
Code:
find ~am0032 -type f -mtime 0 -print0 | tar czvf /respaldo/today.tgz -T - --null
 
Old 05-08-2007, 02:47 PM   #5
zest n zeal
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
thanx a lot

the type f thing fixed it all
 
Old 05-08-2007, 02:53 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Glad we're not one of the worlds best Linux support
sites for nothing ;}


Cheers,
Tink
 
  


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 03:48 AM
a tough question 4 u, problem in extracting tar & tar.gz files p_garg Linux - General 5 11-08-2010 12:02 PM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM
find and tar slackamp Linux - Newbie 4 10-31-2006 02:49 AM
problem unzipping a tar.bz2 file tar: Error is not recov jyome Linux - Software 4 09-04-2003 02:04 PM


All times are GMT -5. The time now is 09:07 PM.

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