Shell parameter size limitation: Argument list too long
:: Tuesday, January 29th, 2008 @ 12:21:48 pm
:: Tags: Computers
I just came across the very-common Argument list too long parameter size issue when running some shell commands during the Wetpixel server migration (currently underway!).
chmod 777 * -bash: //bin/chmod: Argument list too long
I did a bunch of searches in teh Google, and because it took more than 5 minutes to find a good solution, I’m posting more information here.
My goal was to change the permissions of every jpg starting with “post.” At first, I did this (which was recommended by one site):
chmod 777 post*.jpg -bash: //bin/chmod: Argument list too long chmod 777 post-[1-5]*.jpg -bash: //bin/chmod: Argument list too long chmod 777 post-[1-3]*.jpg -bash: //bin/chmod: Argument list too long chmod 777 post-0*.jpg
(etc. etc. etc.)
But then, I found another hint (the comments are the useful part), and tried:
ls post*.jpg | xargs chmod 777
Much cleaner!
Command-line stuff is hard when you're not in that environment a lot.
