Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 878
Vicky Avatar asked Feb 01 '26 12:02

Vicky


1 Answers

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.

like image 83
rob mayoff Avatar answered Feb 04 '26 00:02

rob mayoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!