-1
find /informatica/dev/SrcFiles* -mtime +7 -and -size +1M -exec tar -rvf files.8.2.2013.tar {} \;

This command is running/working correctly and I'm not sure whats wrong. I want to find the files that are over 1MB and older than 7 days and then add them to a single tar file.

closed as unclear what you're asking by Gilles, slm, jasonwryan, user26112, rahmu Aug 3 '13 at 0:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Run the command without the -exec part. Is anything printed? – user26112 Aug 2 '13 at 17:10
  • 4
    How is it failing? Your question states that it is working correctly and you're not sure what's wrong. Is anything wrong? What's the problem if the command is working correctly? – terdon Aug 2 '13 at 17:19
2

The find seems to be just fine:

$ ll
total 3072
-rw-rw-r-- 1 saml saml 1048576 Jan  1  2012 afile1M
-rw-rw-r-- 1 saml saml 2097152 Jan  1  2012 afile2M

$ find . -mtime +7 -and -size +1M 
./afile2M

Adding in the tar seems fine too:

$ find . -mtime +7 -and -size +1M -exec tar -rvf files.8.2.2013.tar {} \;
./afile2M

Looking at the resulting .tar file it seems correct:

$ ll
total 5124
-rw-rw-r-- 1 saml saml 1048576 Jan  1  2012 afile1M
-rw-rw-r-- 1 saml saml 2097152 Jan  1  2012 afile2M
-rw-rw-r-- 1 saml saml 2099200 Aug  2 13:09 files.8.2.2013.tar

$ tar tvf files.8.2.2013.tar 
-rw-rw-r-- saml/saml   2097152 2012-01-01 00:00 ./afile2M

Are you sure there are files that match the criteria?

  • I tried this out too - it works fine for me. – Thomas Shaw Aug 2 '13 at 17:15
  • 1
    This seems kinda hard on the system and slower in that tar is invoked for EACH and very file it finds! I'm definitely not sure that this is a really nice solution. – mdpc Aug 2 '13 at 19:13
  • 1
    @mdpc - agreed. It's not the most efficient way to do this. I was only confirming what the OP was trying and showing that it worked for me. – slm Aug 2 '13 at 19:14
1

I would suggest using cpio over tar .... For example:

 find dirx -depth -print0 | cpio --null -o --format=crc >archive.cpio

You can change crc to tar for OLD tar format, or to ustar for POSIX.1 tar format.

You can omit the --format specification to default to the old CPIO bin format.

Not the answer you're looking for? Browse other questions tagged or ask your own question.