Recursively delete all files with a given name
delete all error_log files | delete files with a certain extension | remove files by pattern recursively | delete all .DS_Store files | find | delete | cleanupWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
find /var/www/vhosts/example.com/httpdocs -type f -name 'error_log' -print -deleteSearches the path including all subfolders and deletes every file whose name matches the pattern. Patterns such as *.tmp or .DS_Store work, the single quotes stop the shell from expanding them first. -print lists every deleted file.
Note: Run it without -delete first and check the list.
Also searched as
- delete all error_log files
- delete files with a certain extension
- remove files by pattern recursively
- delete all .DS_Store files