How to remove all files starting with a certain string in Linux
I need to find all files starting with the name NAME
in a directory tree and remove all these files using one shell command.
To delete all files which name has name, you can use it:
find . -name 'name*' -exec rm {} \;
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.
You can use find
:
find . -name "name*" -exec rm {} \;