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
After researching from many website using search engine, I found several solutions that can remove all message files. First i can use this command
or combine with find
or combine with find and the name of files, example the file starting with "spam-", command to remove is like this
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 :
Another script that can be use :
Another Link :
StevenRoddis
Karkomonline
Moundalexis
| 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 rmAnd, 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}.”
fiecho -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