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)
or
rm -f !(non_delete_file)
find . ! -name non_delete_file -delete
Try
rm `ls | grep -v '^defined$'`
not_defined
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the privacy policy and terms of service.
tagged
asked
11 months ago
viewed
458 times
active
10 months ago