Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To get all the two letters directories using terminal

Tags:

linux

bash

shell

ls

Suppose I have directories like this:

A9
d0
23
12
k3
Folder1
Folder2

I want to find all the directories with just two letter, can anyone give the regular expression for listing all the directories.

Note: I have folders of only the letters A-Z, a-z, and numbers 0-9 combined in 2 letters.

$ ls <some command>

A9
d0
23
12
k3

like image 368
Jimut123 Avatar asked Oct 17 '25 22:10

Jimut123


1 Answers

Use ?? to get all 2 character entries:

ls -ld ??

? matches any single character in shell glob

To list only directories use:

ls -ld ??/

Trailing / lists directories only.

like image 82
anubhava Avatar answered Oct 19 '25 11:10

anubhava



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!