Many new features now available including 2-Factor authentication

Help with command to find username with less than 8 characters

Started by ahsw, November 25, 2019, 03:37:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


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?
Quotewho | grep '[a-zA-Z0-9]\{1,7\}'

The following command here returns 8 character usernames (I have tested and it works)
Quotewho | grep '[a-zA-Z0-9]\{8\}'

Mark Greaves (PCNetSpec)

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 ?
WARNING: You are logged into reality as 'root'
logging in as 'insane' is the only safe option.



So I tried this who | grep "^[a-z0-9]\{1,7\}\s" and it works!!
FWIW I am using MacOS.