简体   繁体   中英

list files with regular expression

How can do I list all files using ls that have atleast 2 digits in their name? I tried this but it gave me error

ls *.log.[1-9][1-9]*.*
ls: *.log.[1-9][1-9]*.*: No such file or directory

I tried this and it list all files that have 0 as the second digit.

ls *.log.[1-9][0-9]*.*

Thanks

You can actually use find command that supports -regex option:

find . -maxdepth 1 -iregex '.*\.log\.[1-9][0-9].*'

-iregex is used for ignore case comparison.

$ ls | egrep '*.log.[1-9][0-9]*.*'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM