Invert the shell command ls under linux

Under Linux, sometimes we only want to keep one file in a certain file, and want to delete the rest. How can we do it quickly?

For example, the following one.

Delete all files in the current directory, but keep the file kahn.bak

ls |grep -v 'kahn.bak' |xargs rm -rf

 

Guess you like

Origin blog.csdn.net/xoofly/article/details/106307374