Answers for "how to remove all files except one in linux"

3

delete all the files without one in linux

# delete all except the filename

$ rm -v !("filename")
Posted by: Guest on August-10-2020
1

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
Posted by: Guest on December-10-2020
0

bash delete everything except

$ rm -v !("filename1"|"filename2")
Posted by: Guest on October-19-2020

Code answers related to "how to remove all files except one in linux"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language