Please tell me how to filter by regular expression using find command in linux?
仅有的幸福
仅有的幸福 2017-06-17 09:16:46
0
1
900

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!

仅有的幸福
仅有的幸福

reply all(1)
迷茫

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template