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: 20 March 2018, 3:53 AM EDT
Location: Simplicity
Posts: 4,008
Thanks: 343
Thanked 1,346 Times in 1,214 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)