How to remove all files starting with a certain string in Linux

Delete all files in current directory and its sub-directories where the file name starts with "foo":

$ find . -type f -name foo\* -exec rm {} \;

NB: use with caution - back up first - also do a dry run first, e.g.

$ find . -type f -name foo\*

will just tell you the names of the files that would be deleted.


I have tried this way it is working for me try below command.

rm -rf Example*

here "Example" is text which is common for all files.


To delete all files which name has name, you can use it:

find  . -name 'name*' -exec rm {} \;

Tags:

Linux

Bash