1

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

Paul R
  • 208,748
  • 37
  • 389
  • 560
Saleem
  • 65
  • 1
  • 5

2 Answers2

2

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.

anubhava
  • 761,203
  • 64
  • 569
  • 643
0
$ ls | egrep '*.log.[1-9][0-9]*.*'
Potherca
  • 13,207
  • 5
  • 76
  • 94
João Cunha
  • 9,929
  • 4
  • 40
  • 61