Friday, March 30, 2012

Argument list is too long

Situation: when I try to ls or rm a "big" folder, mac terminal responds "Argument list is too long".

Solution1: use xargs
ex.
ls chunk*.geojson|xargs rm
find . -type f -name chunk*.geojson | xargs rm
//result: doesn't work in Mac OS

Solution 2:  perl
ex.
perl -e 'for(<./chunk*.geojson>){unlink}'
//this one works in mac os.

Solusion 3: shellscript