delete all files except 1 copy code example
Example 1: delete all the files without one in linux
# delete all except the filename
$ rm -v !("filename")
Example 2: how to remove all files except one in linux
# if you are using a loop
shopt -s extglob
rm -rf !("abc.txt" | "abc.log" ) # others will be removed except these two
shopt -u extglob