How to delete all files containing string in Linux

How to delete all files containing string in Linux

April 27, 2023
find -type f -name '*string*' -delete

This command will delete all files whose filenames contain the string string. The * character is a wildcard that matches any number of characters. The -type f option tells find to only look for files, not directories. The -delete option tells find to delete the files it finds.