Skip to content
Advertisement

Listing files with numeric names

How do I list files that have only numeric names e.g

1111 
2342 
763
71

I have tried ls -l [0-9]* but this seems to bring all file names that start with a digit and can have anything in their name after a digit.

Advertisement

Answer

First, turn on Bash’s extglob option:

shopt -s extglob

Then use this pattern:

ls -l +([0-9])

Read more about extended pattern matching in the Bash Reference Manual.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement