The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 08:33 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 10:43 PM
Unique String azmathshaikh Shell Programming and Scripting 1 08-21-2005 10:38 AM
getline with a unique gozer13 Shell Programming and Scripting 6 03-03-2005 12:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-28-2008
unibboy unibboy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 10
Unique Result

Good day folks,

I am trying to get the logged in users with the 'users' command, but I am having difficulty in making the name of users to appear only ONCE even if they are currenly logged in more than one terminal.

I could not use uniq becuase that only work with lines, but the users command does not print the result in lines.

many thanks in advance
  #2 (permalink)  
Old 01-29-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
One method:

Code:
 users | tr ' ' '\n' | sort | uniq
  #3 (permalink)  
Old 01-29-2008
unibboy unibboy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 10
success

@ jacob

just t say thanks for that, it did work well.

can i just ask if any one can show me how to get the real name of logged in user from the finger command.

when I ran the following command:

finger userLogingName

i got the resul in the following format

Login: xxxxxx Name: yyy xxx
Directory:/home/xxxxxx shell: /bin/bash
on since wednesday 30......
No mail
No plan



but my issue is how to i GET only the name from this output, many thanks
  #4 (permalink)  
Old 01-29-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
Try:

Code:
finger <user_name>  | sed -n '/Login:/p' | sed 's/\(.*\)Name:\(.*\)/\2/'
  #5 (permalink)  
Old 01-29-2008
unibboy unibboy is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 10
mad question

is possible to archieve that without the sed command?
  #6 (permalink)  
Old 01-29-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
Quote:
Originally Posted by unibboy View Post
is possible to archieve that without the sed command?
Code:
finger <<user>> | awk '/Login:/{print $NF}'
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0