Archive for November, 2008

tar: argument list to long

By bo, 17 November, 2008, No Comment

I found that i have over 25.000 files (images) to pack into one (tar) archive. But when i try to add this with : tar cvf my-big-file.tar *.jpg

this fails. The arguments list for the tar command was to long. The *.jpg was the problem and the interpolation under the bash shell.
I revert this command to two commands :

First i made a list of files in the directory that has the pattern *.jpg in the filename.

The find command :

find . -name '*.jpg* > my-file-list.txt

and then i give the tar the list of files that should be added to the archive:

tar cvf my-big-file.tar --files-from my-file-list.txt

Easy :) , if you know the commands :)
I love unix :)