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

LVM: How to remove a volume using pvremove

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

pdftotext not found in CentOS