Skip to content
TrySitePrice

How to delete files containing a character or number/digit in their filename on Linux or Unix

Best/Tutorial

You can delete files containing a character or number/digit in their filename using the find command and the rm command. Here is an example to delete all files containing a digit in their filename: 
find . -type f -name "*[0-9]*" -delete

Explanation:

  • find .: Find files in the current directory.
  • -type f: Find only files (not directories).
  • -name "*[0-9]*": Find files whose names contain a digit.
  • -delete: Delete the files found.