I have a directory containing a large number of files. I want to delete all files except for file.txt . How do I do this?
There are too many files to remove the unwanted ones individually and their names are too diverse to use * to remove them all except this one file.
Someone suggested using
rm !(file.txt)
But it doesn't work. It returns:
Badly placed ()'s
My OS is Scientific Linux 6.
Any ideas?
.git
目录,请参阅:stackoverflow.com/a/22347541/565877