delete multiple files/directory with exclusion

I have multiple files in a directory and I was logged in thru my bash shell. Then I just issue the command below.


rm -rf $(ls|grep -E '[^(^ext$)|(mootools)]')


grep -E will execute an extended regular expression so ext and mootools will be retain or excluded upon deletion of files in the current directory.

Comments

Popular posts from this blog

Using Oracle 11g thru VirtualBox appliance in Mac OS X Lion

Use Shell Editor for Eclipse for editing bash, ksh, csh in Unix/Linux system

LVM: How to remove a volume using pvremove