In Linux, search and delete files starting or ending with any character

by Koree S. Monteloyola

 

1. In your terminal go to the path of the parent directory or top folder, wherein you want to start searching for the files

2. Execute this command to find the files ending with "~"

find . -name "*.*~" -exec ls {} \;

3. Execute this command to find the files starting with "~"

find . -name "~*" -exec ls {} \;

4. Execute this command to delete the files ending with "~"

find . -name "*.*~" -exec rm -f \;

5. Execute this command to delete the files starting with "~"

find . -name "~*" -exec rm -f \;

 

Hope this helps!

blog comments powered by Disqus