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

www.lau‮.irutt‬com
How to delete files containing a character or number/digit in their filename on Linux or Unix

To delete files containing a character or number in their filename on Linux or Unix, you can use the find command with the -delete option.

Here is an example of how to delete all files in the current directory that contain the character a in their filename:

find . -name "*a*" -delete

This will delete all files in the current directory that contain the character a in their filename.

To delete all files in the current directory that contain a number in their filename, you can use the -regex option with the find command:

find . -regex ".*[0-9].*" -delete

This will delete all files in the current directory that contain a number in their filename.

Note that the find command can be dangerous, as it will delete all files that match the specified criteria without prompting for confirmation. Make sure you are deleting the correct files and that you have a backup of any important files before using this command.

Created Time:2017-10-28 21:39:02  Author:lautturi