Posted: . At: 6:47 PM. This was 7 years ago. Post ID: 10385
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.

Use ls to only list files that start with an uppercase character.

The ls command may be used in conjunction with grep to list files that start with an uppercase letter or have an uppercase filename.

┌──(john㉿DESKTOP-PF01IEE)-[~/Documents]
└─$ ls | grep "^[A-Z]"
Boomsrc
Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f140.m4a
Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f160.mp4
Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].mp4
The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].3gp
The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].webm
Wallpaper

Another way to do this is with this one-liner, this will do this admirably.

┌──(john㉿DESKTOP-PF01IEE)-[~/Documents]
└─$ ls -dlaH /home/john/Documents/*[[:upper:]]*
drwxr-xr-x 3 john john    4096 Sep 22 08:22  /home/john/Documents/Boomsrc
-rw-r--r-- 1 john john 4017633 Nov  8  2018 '/home/john/Documents/Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f140.m4a'
-rw-r--r-- 1 john john 2010731 Nov  8  2018 '/home/john/Documents/Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f160.mp4'
-rw-r--r-- 1 john john 6089523 Nov  8  2018 '/home/john/Documents/Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].mp4'
-rw-r--r-- 1 john john 1906983 Aug  7 02:23 '/home/john/Documents/The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].3gp'
-rw-r--r-- 1 john john 3808743 Aug  7 02:20 '/home/john/Documents/The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].webm'
drwxrwxrwx 2 john john   20480 May 30 09:16  /home/john/Documents/Wallpaper

This is not too hard to do at all.

And yet another example.

┌──(john㉿DESKTOP-PF01IEE)-[~/Documents]
└─$ ls -lHd -- *[[:upper:]]*
drwxr-xr-x 3 john john    4096 Sep 22 08:22  Boomsrc
-rw-r--r-- 1 john john 4017633 Nov  8  2018 'Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f140.m4a'
-rw-r--r-- 1 john john 2010731 Nov  8  2018 'Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].f160.mp4'
-rw-r--r-- 1 john john 6089523 Nov  8  2018 'Hope is the good thing(The Shawshank Redemption 1994). [JAmspaaSNzE].mp4'
-rw-r--r-- 1 john john 1906983 Aug  7 02:23 'The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].3gp'
-rw-r--r-- 1 john john 3808743 Aug  7 02:20 'The Delta Flyer is Attacked by the Borg Cube [Bpunt6Ffl3c].webm'
drwxrwxrwx 2 john john   20480 May 30 09:16  Wallpaper

There are a few ways to list files with uppercase characters in the filenames, but this should really help out. It is a very useful tip.

This works so well.

To list all words in the /usr/share/dict/words file that can be spelled with the letters A to F, use the command below. This prints them all in upper case.

┌──[jason@11000000.10101000.00000001.00000010][~]
└──╼  ╼ $ grep -iP '^[a-eosi]{3,}+$' /usr/share/dict/words | tr [:lower:] [:upper:]
AAA
ABC
ABCS
AIDS
AIS
ASCII
ASCIIS
ABBAS
ABBASID
ABE
ACADIA
ADA
ADAS
ADDIE
ADIDAS
AIDA
ASIA
ASSAD
ASSISI

1 thought on “Use ls to only list files that start with an uppercase character.”

Leave a Comment

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