Delete files except those whose name matches a string
问题 I'm trying to delete all files (include subdir) in a directory but only files which not match specific file name: "equipe" "match" "express" I'm trying to do it with this command find . -type f '!' -exec grep -q "equipe" {} \; -exec echo rm {} \; That doesn't work. It echos files with "equipe" inside How can I do it with multiple strings? ("equipe" "match" "express") 回答1: You may use this find : find . -type f -not \( -name '*equipe*' -o -name '*match*' -o -name '*express*' \) -delete 来源: