I used locate <filename> in order to see where are all the files with <filename>. Is there a command to delete all the files with that <filename>?
For example, I want to delete all the files with the name qownnotes as in image
Asked
Active
Viewed 65 times
0
1 Answers
0
Using the find command, you can do a search for and subsequently execute an action.
find / -iname \*qownnotes\* -exec rm -rf {} \;
This above command searches the file system, starting at the root level, case insensitive in the name, and matches files or directories. The qownnotes string can be at any place in the file or directory name, indicated by the first escaped asterisk and the ending escaped asterisk.
When it finds a match, it will execute the remove command, with the recursive and force attributes. The search results will populate into the brackets, and the ending slash and semicolon prevent escaping.
As written above, it will remove all files it finds without confirmation, so be sure it is what you're wanting to do before running it.
user117197
- 1
- 2