Get past "argument list too long" using xargs
Submitted by jeff on Tue, 05/27/2008 - 17:22.
Recently I kept geting “Argument list too long” error while trying to delete about 12,000 files from a directory. It was simply too much for rm * to handle.
[mycomputer:~ bob$ rm * bash: /bin/mv: Argument list too long
To get around this you do this:
ls | xargs rm
That will pipe the ls output as an argument to rm until everything is gone. Very excellent. This will work with other shell commands as well.
Recent blog posts
- Amazon S3 Website CNAME
- Button labels for checkout
- Insert html django contrib messages
- Twitter Bootstrap not working with LESS.js
- Javascript libs that offer basic subset of jquery features
- Building the donor-matic
- Playing with free Google Map alternatives.
- Some flows are not as complicated as they appear
- Form design crib sheet
- Script to get IE9 Windows Virtual PC images into Virtual Box