I wanted to remove a large number of files from a directory. However, I did not want to descend into subdirectories, nor did I want to remove any .pdf or .chm files. Some of the files had non-standard characters (such as quotes and spaces) in them.
The solution? A simple one liner using find and xargs:
|
1 |
$ find . \( ! -name "*.pdf" -a ! -name "*.chm" \) -maxdepth 1 -type f -print0 | xargs -0 rm |