Help with command to find username with less than 8 characters

I just started taking a linux course and am stuck with my assignment.

I need to find the usernames of logged-in users with usernames of fewer than 8 characters. Here is the command that I have tried but it is not working. Would someone please advise what I may have done incorrectly?

who | grep '[a-zA-Z0-9]\{1,7\}'

The following command here returns 8 character usernames (I have tested and it works)

who | grep '[a-zA-Z0-9]\{8\}'

I’m lost why your last command doesn’t work if it has to be FEWER than 8 characters (?)

who | grep '[a-zA-Z0-9]\{8\}'

should do <=7 characters (and skip anything with >=8) … so what am I missing ?

I ran the command line on my pc and it worked. :slight_smile:

So I tried this

who | grep "^[a-z0-9]\{1,7\}\s"

and it works!!
FWIW I am using MacOS.

:-X :-X :-X