Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

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
OR
rm -v !(*.zip|*.odt)

shopt -u extglob 
 
PREVIOUS NEXT
Tagged: #remove #files #linux
ADD COMMENT
Topic
Name
4+9 =