Can I know how to remove all *.sln file but exclude "work.sln" in the same folder
I try run rm *.sln !("work.sln")
it return /bin/bash: eval: line 128: syntax error near unexpected token
('`
Thank you
Can I know how to remove all *.sln file but exclude "work.sln" in the same folder
I try run rm *.sln !("work.sln")
it return /bin/bash: eval: line 128: syntax error near unexpected token
('`
Thank you
Assuming you are already inside the folder that contains the files you need, this is one way to do it (also assuming you are looking for a one-line version, given your example)
for file in $(ls);do if [[ ! $file == work.sln ]]; then rm $file; fi; done
EDIT: as @tripleee pointed out, the ls
can be avoided and re-written like this
for file in *; do if [[ ! $file == work.sln ]]; then rm $file; fi; done