Search code examples
linuxunixls

Using wildcard with 'ls'


I want to list the all files having a name like these:

12.0.3.1_CA
12.0.3.2A_CA
12.0.3.2B_CA

I tried

ls -ltr 12.0.3.?*_CA

That worked, but fails when I have files like:

12.0.3.2AA_CA
12.0.3.2A2_CA

Solution

  • If you want only one character at max after the '?' then try:

    ls -ltr 12.0.3.?[*]_CA
    

    [] is used to encase any character you want, like if we want to have 'ac' in the name we would use [ac].