I found a weird error message when I tried to delete some files in my linux box today. The command I used was
sudo rm -rf *.jsto delete some .js files, and I got an error message:
sudo: unable to execute /bin/rm: SuccessAfter googling around, I found this wonderful site, and the solution is to use find coupled with -exec flag rather than rm:sudo find . -iname '*.js' -exec rm {} \;
The problem is, according to the site, was caused by buffer overflow when expanding the *.The single quote that we used in the find command will prevent it from expanding and causing overflow. So, that's all folks.
1 comment:
Thanks for the help on a weird error. But use a "-maxdepth 1" or appropriate flag, as 'find' recurses by default, where "rm" does not. This:
% cd / ; sudo rm l* # might be benign
% cd / ; sudo find . -name="l*" -exec rm {} \; # would remove, /bin/ls, for example.
Post a Comment