Hello Experts,
This is regarding framing RegEx for the likes 'tv5XXXX'.
Their are directories under say 'myFolder/' with names like:
tv5abc1
tv5abc2
tv5jkh6
tv5jkhi
.
.
and others out of my concern. I want to list all the directories of my required type. Their name must fulfill the following condition:
- begin with 'tv5'
- contain no special character, only alphanumeric
- 'tv5' can be followed by 4 alphabets(eg tv5abcd) or 3 alphabets and the last one, a digit(eg tv5abc2).
I made the following towards achieving the solution:
ls -l | awk '{print $9}' | grep "^\(tv5[a-z]\{3,4\}[0-9]\{1\}\)$"
The above snippet lists the likes of tv5ebc1, tv5abc2 etc. and not tv5abcd because it looks for a number in the end.
What I think the solution to be is :
ls -l | awk '{print $9}' | grep "^\(tv5[a-z]\{3\}{--either a digit or an alphabet--}\)$"
Please provide some hints to help me.
Thank You.
Regards