If I pipe ls
to grep
, how would I be able to return a list of files with the condition that they only have an x amount of letters, extension included?
So for example, if ls
gives me:
abcde.jav a156e.exc test.c prog1.c qwert r.c
and I'm looking for all files that contain strictly 5 letters, extensions included:
a156e.exc test.c prog1.c qwert
I've tried:
ls | grep '^[a-z]${5}'
ls | grep "^[a-z]|[a-z]$"
and other things like that, but I can't seem to get it. It seems like the solution should be really simple but I can't figure it out. Any help would be appreciated.