• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i finish this commmand

 
johny doe
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find all logged-in users with usernames of at least 4 characters ??

i know that in order to get all logged in users and only the names
i need
who|cut -d" " -f1|uniq

know how do i continue the command so it will find
usernames of at least 4 characters ??

i am not sure that my way is the right one

so feel free to give other versions
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use grep and some regular expression for that. That's if you want to make it into one single command. If you're allowed to bash script, then that's should be fairly straightforward.
 
johny doe
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to do it in one command
how do i use grep here??

how do i test the length of the user name?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pipe the result through "grep", and use a regular expression that says "four characters, optionally followed by more." I'm assuming this is a school assignment, so I'm not going to actually type the command for you, but hopefully this is enough.
 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this command

who | cut -d "|" -f1 | uniq | awk 'length>3'
[ December 23, 2007: Message edited by: minal silimkar ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic