Remove all files apart from some specified

From MyWiki
Revision as of 12:02, 6 January 2015 by George2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

< source lang="text">

    1. Delete all file except file1 ##

rm  !(file1)

    1. Delete all file except file1 and file2 ##

rm  !(file1|file2)

    1. Delete all file except all zip files ##

rm  !(*.zip)

    1. Delete all file except all zip and iso files ##

rm  !(*.zip|*.iso)

    1. You set full path too ##

rm /Users/vivek/!(*.zip|*.iso|*.mp3)

    1. Pass options ##

rm [options]  !(*.zip|*.iso) rm -v  !(*.zip|*.iso) rm -f  !(*.zip|*.iso) rm -v -i  !(*.php) </source>