Posted: . At: 11:07 AM. This was 6 years ago. Post ID: 12136
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to list files with ls that start with letters in the filename and then have numbers.


This is how to list some filenames that start with letters and have some numbers in the filenames. This is a very useful Linux trick.

jason@Yog-Sothoth » ~ » $ ls -l [A-Z]*[0-9]*.wav
-rw-rw-r-- 1 jason jason 4399528 Oct 25  2017 gqrx_20171024_232212_33050000.wav
-rw-rw-r-- 1 jason jason 2378004 Oct 29  2017 gqrx_20171029_001507_126954900.wav
-rw-rw-r-- 1 jason jason 2302460 Feb  6 07:52 gqrx_20180205_205246_469216400.wav
-rw-rw-r-- 1 jason jason 9810184 Feb  6 08:02 gqrx_20180205_210208_469215900.wav

These are the filenames I am after.

gqrx_20171024_232212_33050000.wav
gqrx_20171029_001507_126954900.wav
gqrx_20180205_205246_469216400.wav
gqrx_20180205_210208_469215900.wav

Therefore, this is a very useful trick, I can filter the output of ls to only show the files I am after.

The [A-Z] and [0-9] operators are very useful to know about when creating an expression to filter text. Give this a go yourself and see what you can come up with.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.