These options will struggle with too many filenames because xargs will produce multiple commands from the list. The command xargs (as I understand it) will take the input list and try to make a single command line from the options given using the input as described or as the final part of the line by default. If the line is going to exceed the maximum command length, then xargs will loop on the command with the remaining input.
With a tar this could be disastrous because the potential multiple tar commands would not be able to be disentangled if you needed to read it back.
If this was AIX, I would recommend writing the names of the required items into a temporary file and passing that with the -L flag, but I'm not sure that HP-UX or anything else supports that. Solaris might use -I (capital i) instead. You would have to read the manual page and look for a flag to accept a list or input file.
Hmmm - isn't it that tar expects the files to create an archive from on the command line? Doesn't it use stdin only when extracting from a data stream?
So xargs WOULD be needed to supply the file names coming from find on stdin as parameters on the command line to tar .
tar: Under linux you can use -T - to read filenames from stdin.
Pack:
find /path -type f | tar -T - -cf - | gzip >file.tar.gz
Unpack:
gzip -dc file.tar.gz | tar -xf -
I doubt that HP-UX tar already has this option. But maybe. I recommend cpio as the better option here too, because it's designed right from start to work with files from stdin.
tar -cvf has not argument for -f. What was recommended to you is this command(dash at the end): tar -cvf -
I tried all commands that I received and only one works properly for me. (at least, a GZIP file is created.) I will verify the contains.
Below the 3 tests that I did :
test 1 ==> seems to work well
find * -type f -mtime -100 -exec tar cf - {} + | gzip > $MAITUT/BCK_DATA.tar.gz
Result :
-rw-rw-r-- 1 maitdev mait 290757296 Aug 8 09:04 BCK_DATA.tar.gz
find * -type f -mtime -2 -exec tar cf - {} + | gzip > $MAITUT/BCK_DATA.tar.gz
result :
-rw-rw-r-- 1 maitdev mait 7876 Aug 8 09:12 BCK_DATA.tar.gz
test 2
find * -type f -mtime -900 -print | tar -cvf - | gzip > $MAITUT/BCK_DATA.tar.gz
Result :
Attempt to create archive of no files. Nothing dumped.
test 3
find * -type f -mtime -900 -print -exec tar cvf {} \; && bzip2 *.tar
result :
4fa056a8
Attempt to create archive of no files. Nothing dumped.
ARCNEWLD.dat
Attempt to create archive of no files. Nothing dumped.
ARCNEWLD.idx
Attempt to create archive of no files. Nothing dumped.
ARCNEWLD.sfd