To delete all files except one!
- using find
- using zsh:
- using bash:
to delete all except filename1 and filename2
Bash Specific Use Globignore variable
it will remove all except iso and text file
#notes #challenges
- using find
find . \! -name 'file' -delete
- using zsh:
setopt extendedglob
echo ^foo
rm ^foo
- using bash:
shopt -s extglob
rm -v !("filename")
rm -v !("filename1"|"filename2")
to delete all except filename1 and filename2
Bash Specific Use Globignore variable
GLOBIGNORE=*.iso:*.txt
rm *
unset GLOBIGNORE
it will remove all except iso and text file
#notes #challenges