Delete all files in a folder that don\’t match a certain file extension

$ rm !(*.foo|*.bar|*.baz)

Deletes all files in a folder that are NOT *.foo, *.bar or *.baz files. Edit the pattern inside the brackets as you like.

\"\"

by David Winterbottom (codeinthehole.com)

\"\"
\"\"

\"\"

URL: http://feedproxy.google.com/~r/Command-line-fu/~3/TCRb2ku_V1Y/delete-all-files-in-a-folder-that-dont-match-a-certain-file-extension

\"Reblog

1 thought on “Delete all files in a folder that don\’t match a certain file extension”