bash error: argument list too long
March 12th, 2007 by RohanIf you need to process a large number of files on the command line, you might get an error from bash (1), if the number of files are huge.
I needed to process around 13k HTML files, so my first move was to get all these files into a tar (1) file. The following command gives an error -
$ tar cf - *.html > all_html_files.tar
bash: /bin/tar: Argument list too long
One solution is to use find (1) in combination with xargs (1) as follows -
$ find . -name ‘*.html’ | xargs tar cf - > all_html_files.tar
Note the single quotes surrounding *.html. This goes directly to the find command without bash trying to expand the argument list.
More info is here.
