Argument list too long

Well, if that is the error you are getting on your Linux box then it looks like you have just got too many things that you are trying to run through the mill in your shell.

I stumbled accross this one

Basic reason being how the shell handles wildcards. If the list gets too long, the above error appears. So it is not the program running into trouble, but your shell.

If you are just using „ls“ you can do this simple trick:

ls | grep ".txt"

Here you are not using any wildcards. No expansion happening. The following grep command is picking the files with the extensions for you.

If you don’t just want to see the files, but use the list the above will not get you too far. Instead we use „xargs“. This nice little tool reads a list of file names and splits them into chewable bits.

If for example all files with the ending „.txt“ are to be stuffed into a tar archive, you would use the following line:

ls | grep ".txt" | xargs tar -rf TextArchiv.tar

So, ls will list all files, grep will return all files with the „.txt“ ending and xargs splits the list into a bunch of blocks and calls up the tar command with each block of data. The „-r“ is what ensures that the blocks are joined into one in the archive.

So, hope this helps someone.