I want to delete all files & directories in a folder say 'A'. But except one file in that folder say .keep. I have tried the following command.
find A ! -name '.keep' -type f -exec rm -f {} +
But above command also deletes folder A. I do not want that. There are several answers related to this. But they all mentions going into that directory. I want to mention that directory in the command without cd-eing into the directory.
Answer
find A ! -path A/.keep -a ! -path A -delete
No comments:
Post a Comment