I need to delete all files, except one (its name is defined), from a given directory.
How can I do this from the terminal in OS X? Can I do this with one single command?
shopt -s extglob && rm !(non_delete_file)
rm -f !(non_delete_file)
find . ! -name non_delete_file -delete
rm `ls | grep -v '^defined$'`
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the
terms of service.
11 months ago
10 months ago