Today I was limited by rm
I needed to clean up a folder by deleting previous years (2008) log files which amounted to a few thousand files
rm logs-2008*
returned me the error
/bin/rm:Argument too long
The reason for this error is a limitation of your running kernel and will limit you to other commands as well. Like mv and cp, if the amount of files you want to act on is larger than the set limitation.
a work around is to pipe the matching files to rm one at a time.
To do this, issue the following command
find -name 'log2008*' | xargs rm (substitute 'log2008*' for your search string)
If the files you are trying to remove have spaces in them, then you need to use the following command
find -name 'log2008*' | -print0 | xargs -0 rm
No comments:
Post a Comment