List only numeric file names in directory


I have a list of files with numeric file names (e.g. #.php, ##.php or ###.php) that I’d like to copy/move in one fell swoop.

Does anyone know of an ls or grep combo command to accomplish this objective?

I do have this much:

ls -al | grep "[0-9].php"


You can use regular expression when listing files:

ls [0-9]*

This was an easy and minimalistic approach at the above problem but I think a better solution is

ls -al | grep -E '^[0-9]+\.php$'

as UncleZeiv explains below.

Answered By – ppolyzos

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published