Reputation: 9431
I have ~5k files that I wish to unzip.
2:13:35 2017-01-16 $ unpigz *.gz
-bash: /usr/local/bin/unpigz: Argument list too long
12:13:40 2017-01-16 $ unpigz -r *.gz
-bash: /usr/local/bin/unpigz: Argument list too long
12:15:45 2017-01-16 $ gunzip *.gz
-bash: /usr/bin/gunzip: Argument list too long
12:17:56 2017-01-16 $ cp *.gz ~/Desktop/
-bash: /bin/cp: Argument list too long
Is there a count limit to the amount of files bash can handle?
Upvotes: 0
Views: 2704
Reputation: 530823
The limit is not on the number of arguments, but on the combined length of the command line and the environment. (Informally, this means the more strings in your environment, the shorter the command line can be.) This limit is specific to the operating system, not any particular command. To work around this, use find
to invoke your command repeatedly.
find . -prune -name '*.gz' -exec gunzip {} +
Here, gunzip
will be called with as many arguments as possible, and repeatedly until all the matching files have been unzipped.
Upvotes: 7