Skip to main content

/bin/rm: Argument list too long

After a few weeks i have not open my mail box, i found many spam in one folder. So, i decide to remove all messages. Using console, i go to the directory. When i try to remove the files using command
| rm -rf *
There is an error message :

/bin/rm: Argument list too long

After researching from many website using search engine, I found several solutions that can remove all message files. First i can use this command
ls | xargs rm

or combine with find
find . | xargs rm

or combine with find and the name of files, example the file starting with "spam-", command to remove is like this
find . -name 'spam-*' | xargs rm

If filenames had any spaces you will need to do use find's "-print0" option in conjunction with xargs's "-0" option. otherwise the shell that xargs uses to execute the "rm" command line will treat the space as a token separator, thereby treating the name as two (or more)names, none of which are the thing you're trying to actually delete. The command line should look like this :
find . -name 'spam-*' -print0 | xargs -0 rm
And, my maildir was clean.

Another script that can be use :

wipe() {
if [ “${1}” == “” ] ; then
echo “Wiping out all non-directory files in ${PWD}.”
else
echo “Wiping out all files starting with ‘${1}’ in ${PWD}.”
fi

echo -n ‘Type “YES” to confirm: ‘
read YESNO
if [ “${YESNO}” != “YES” ] ; then
echo ‘Maybe next time.’
return 0
fi

# ok, wipe it
find . \( -name “${1}*” -and \! -name “.*” -and -type f \) -print0 | xargs -0 rm
}


Another Link :

StevenRoddis
Karkomonline
Moundalexis

Comments

Popular posts from this blog

Extend a LVM partition after increasing its virtual disk on Virtualbox

No Linux machine at work? the easy way could be to simply install Virtualbox in one of the PC, create a VDI and install Ubuntu 14.04 in it. But the day will come when you need more space! Here is how to resize it: Resize Virtualbox VDI Open Virtualbox, make sure to shutdown your virtual machine. Then open a terminal (here windows): 1 2 3 4 cd “ C : \ Program Files \ Oracle \ VirtualBox ” VBoxManage list vms VBoxManage clonehd uuid 0000000000000000 backup . vdi VBoxManage modifyhd uuid 0000000000000000 -- resize 204800 This is the Virtualbox official manual  of available commands. And  this is a website  to convert Gb into Mb (–resize takes Mb as input, 200Gb = 204800Mb). Boot Gparted to resize the partition After a default install of Ubuntu Server on one physical disk, you will have a SWAP partition, and then an extended partition in which you’ll have your LVM partition (So 3 partitions).  Download Gparted  .iso,...

Website Using HTTPS Protocol

Last week, I changed protocol of my website from http to https. There were steps that i had to do. First, I installed openssl package and mod_ssl # yum install mod_ssl openssl Then, I configured the openssl  and created certificate # cd /etc/pki/tls/certs # make server.key # openssl rsa -in server.key -out server.key # make server.csr # openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650 # chmod 400 server.* After that, I changed configuration of httpd/apache #nano /etc/httpd/conf.d/ssl.conf DocumentRoot "/var/www/html" ServerName www.server.world:443 SSLCertificateFile /etc/pki/tls/certs/server.crt SSLCertificateKeyFile /etc/pki/tls/certs/server.key Last, I restarted the webserver #service httpd restart That's all what i did last week to change my website protocol from http to https.

Privacy Policy

Another Pratama Privacy Statement What follows is the Privacy Statement for all Another Pratama websites (a.k.a. blogs) including all the websites run under the computer.pratama.us domain. Please read this statement regarding our blogs. If you have questions please ask us via our contact form. Email Addresses You may choose to add your email address to our contact list via the forms on our websites. We agree that we will never share you email with any third party and that we will remove your email at your request. We don’t currently send advertising via email, but in the future our email may contain advertisements and we may send dedicated email messages from our advertisers without revealing your email addresses to them. If you have any problem removing your email address please contact us via our contact form. Ownership of Information Another Pratama is the sole owner of any information collected on our websites. Comments/Message Boards Most Another Pratama websites contain com...