having issue with tar and find programs under Ubuntu 11.10
Hello,
Basically what I'm trying to do is tar up a bunch of files on my system. I want to use tar to create the archive and use find to get all of the files to be archived. I want all of the logfileson my system in this archive. Here is what happened, and it makes no sense. Wht's going on? What am I doing wrong? Thanks for your help! root@techwizard:~# tar -cf logs2012-05-09.tar > find / -name '*.log' tar: invalid option -- 'e' Try `tar --help' or `tar --usage' for more information. root@techwizard:~# |
you can use the -exec option of find.
Code:
fukawi1 /var/log # find . -iname '*.log' -exec tar -czvf /tmp/tmp.tar.gz '{}' \; |
Quote:
|
rknichols is correct.
You need to use xargs and these links might help. http://www.linuxquestions.org/questi...pected-856455/ http://linuxgazette.net/111/tag/4.html |
Using xargs can silently fail too if the argument list becomes longer than what can be passed in a single exec() call. To be ironclad, you need to pass all the names null-terminated to a single invocation of tar:
Code:
find / -name '*.log' -print0 | tar -cf logs2012-05-09.tar --null --files-from - |
Good catch, in my defense, that was a cut and paste error there of a command I tried erroneously working on reaching the below example, which is what should have been pasted. Apologies for the confusion..
Code:
fukawi1 /var/log # find . -iname '*.log' -exec tar -rvf /tmp/test.tar '{}' \; Learn something new every day, as they say. |
All times are GMT -5. The time now is 10:57 PM. |