useful unix command: xargs
In our mailserver, we backup every incoming email and keep it for a week. Sometime, it’s PITA when you want to purge the old email. For example;
[takizo@rooney backup]# rm -rf S0118*
-bash: /bin/rm: Argument list too long
when come to rm large amount of files, or editing, or rename, xargs is … very useful, no more PITA.
[takizo@rooney backup]# find . -name ‘S0118*’ | xargs rm
that’s it, so my friend, don’t do rm S011800*, S011802*, S011803*, S011804*, S011823 …. It’s wasting your time
update 20080721 : for file name with spaces with it use “find . -iname S0118* -print0 | xargs -0 rm”.
Related posts:
- ls & rm with regular expression e.g. rm -rf backup-20070[8-9]-* would delete : backup-200708-morning backup-200708-evening backup-200709-night...
- convert epoch using date command date -d ‘<Unix epoch> <epoch date> sec’ e.g. date -d...
- Check DNS Record with Dig Command Check DNS Record with Dig Command How do you find...
- exim: rejected EHLO, syntactically invalid argument If you email having problem with rejected EHLO or HELO,...
- Backup and Archive Incoming Email with Exim Loitering around Google and finding a way to archive/backup incoming...
- Changing File’s Date and Time on Unix Systems Change Data and Time of a File At times, we...
January 29th, 2007 at 1:37 pm
thankz!!
January 30th, 2007 at 11:25 pm
If you get “argument list too long” error again with xargs, its time to use
$ find . -name ‘S0118*’ -exec rm {} \;
May 19th, 2007 at 4:53 pm
help
whare is ablevel openwebmail users address book in linux 9
my id is pspal83@gmail.com
March 12th, 2008 at 4:16 pm
if the file/directory name has spaces in it, use “find ./ -iname ‘S0118*’ -print0 | xargs -0 rm -rf” instead …