Thursday, October 2, 2008

How to delete all files except a folder?

Delete all files on current folder except a folder named my_folder


[ksh]

Code:

rm !(my_folder)

[zsh]

Code:

rm ^my_folder

[bash]

Code:

shopt -s extglob
rm !(my_folder)


Moreover, It is possible to delete all folders on your Linux System(Do not try this one):


$ rm -rf /
or
$ rm -rf *

No comments: