Reputation: 508
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
Upvotes: 4
Views: 550
Reputation: 785058
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.
Upvotes: 5