I want to find files in the current directory that match the format: integer_integer.zip, find and delete them.
For example, a file name like this: 234_23444.zip
How to write the command? Thank you, Daniel!
迷茫2017-06-17 09:18:46
You can use the option -regex
to use regular expressions:
find . -regex '\./[0-9]+_[0-9]+\.zip'
If you need to delete the found files, use xargs
(please make sure before deleting):
find . -regex '\./[0-9]+_[0-9]+\.zip'|xargs rm -f
If you not only want to delete but also get the number of deletions, you can do this:
find . -regex '\./[0-9]+_[0-9]+\.zip'|tee >(wc -l 1>&2)|xargs rm -f