问题
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
来源:https://stackoverflow.com/questions/51951725/delete-files-except-those-whose-name-matches-a-string