removce everything excelpt one file 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
Example 3: bash delete everything except
$ rm -v !("filename1"|"filename2")