One Quickie


tar + xargs for huge numbers of files (Unix->General)
If you have too many files to add to a tarball, you can run into the shell's command limitation. If you use xargs + tar cf, you'll not get all of your files added to the tarball. Use tar's rf command to append to an archive rather than creating one:
% find . -name "*.yuck" -print0 | xargs -0 tar rvf oop.tar
-print0 (zero) tells find to output the filenames with trailing NUL characters (rather than newlines), and -0 tells xargs to use a NUL as its input separator, rather than newlines/spaces. The upshot is that you can handle filenames with spaces in them.

Thanks to Ben Cox for the -print0 / -0 suggestion.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com