Unix/Linux Go Back    

Rm all files but two

Shell Programming and Scripting

Kindly Note - This is a Single User Post by Forum Member MadeInGermany Regarding:
Rm all files but two.
Please Follow The Primary Link Above to View the Full Discussion.

Old Unix and Linux 07-12-2017   -   Original Discussion by mohtashims
MadeInGermany's Unix or Linux Image
MadeInGermany MadeInGermany is offline Forum Staff  
Join Date: May 2012
Last Activity: 15 December 2017, 6:52 AM EST
Location: Simplicity
Posts: 3,868
Thanks: 320
Thanked 1,289 Times in 1,167 Posts
I think your pattern is wrong.
Should be

ls -ld /tmp/data/!(output.txt|hello.txt)

If not 100% confident, test with ls -ld first, then run rm -rf.
The Following User Says Thank You to MadeInGermany For This Useful Post:
mohtashims (07-12-2017)