Unique Result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unique Result
# 1  
Old 01-28-2008
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  
Old 01-29-2008
One method:

Code:
 users | tr ' ' '\n' | sort | uniq

# 3  
Old 01-29-2008
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  
Old 01-29-2008
Try:

Code:
finger <user_name>  | sed -n '/Login:/p' | sed 's/\(.*\)Name:\(.*\)/\2/'

# 5  
Old 01-29-2008
mad question

is possible to archieve that without the sed command?
# 6  
Old 01-29-2008
Quote:
Originally Posted by unibboy
is possible to archieve that without the sed command?
Code:
finger <<user>> | awk '/Login:/{print $NF}'

# 7  
Old 01-29-2008
please dont hate me

Quote:
finger <<user>> | awk '/Login:/{print $NF}'
Let me apologise for being a pain jacob, but i trying not to use sophisticated command like sed or awk, to accomplish the task
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count occurrence of column one unique value having unique second column value

Hello Team, I need your help on the following: My input file a.txt is as below: 3330690|373846|108471 3330690|373846|108471 0640829|459725|100001 0640829|459725|100001 3330690|373847|108471 Here row 1 and row 2 of column 1 are identical but corresponding column 2 value are... (4 Replies)
Discussion started by: angshuman
4 Replies

2. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

3. UNIX for Dummies Questions & Answers

Print unique lines without sort or unique

I would like to print unique lines without sort or unique. Unfortunately the server I am working on does not have sort or unique. I have not been able to contact the administrator of the server to ask him to add it for several weeks. (7 Replies)
Discussion started by: cokedude
7 Replies

4. Shell Programming and Scripting

Select Unique Value

HOW CAN I SELECT AN UNIQUE STRING FROM A FIELD? ACTUALLY I WANT TO PRINT RECORDS THAT 2ND FIELD OF THAT HAVE ONE CHARACTER AND IT MUST BE "P" AWK '$2~"" {PRINT $0}' IN > OUTBUT THIS CODE PRINT ALL RECORDS WHICH 2ND FIELDS OF THEM START WITH "P" AND MAY CONTAINS ANOTHER CHARACTER! (1 Reply)
Discussion started by: saeed.soltani
1 Replies

5. Shell Programming and Scripting

Change unique file names into new unique filenames

I have 84 files with the following names splitseqs.1, spliseqs.2 etc. and I want to change the .number to a unique filename. E.g. change splitseqs.1 into splitseqs.7114_1#24 and change spliseqs.2 into splitseqs.7067_2#4 So all the current file names are unique, so are the new file names.... (1 Reply)
Discussion started by: avonm
1 Replies

6. UNIX and Linux Applications

unique

Can anyone tell me what unique does? I accidentally typed unique instead of uniq into my terminal and it accepted it. I can't find a man page, an info page, or anything useful on google. (1 Reply)
Discussion started by: cokedude
1 Replies

7. HP-UX

groupadd not unique

I want to add several users and several groups to a HPUX 11.31 box. When I type groupadd -g GID <name>, I'm told GID is not unique....even though it doesn't exist in the /etc/group file. I read in the man pages about NIS but I don't think we are using NIS....well we are using LDAP, but can... (1 Reply)
Discussion started by: jackiebaron
1 Replies

8. Shell Programming and Scripting

get part of file with unique & non-unique string

I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM". I can find the line number for the beginning of the statement section with sed. ... (5 Replies)
Discussion started by: andrewsc
5 Replies

9. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

10. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies
Login or Register to Ask a Question