Need help finding number of logins!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help finding number of logins!
# 1  
Old 04-22-2008
Need help finding number of logins!

Let's say I am trying to find out how many times someone has logged into the machine. Use last to display all the different logins, several names pop up, some multiple times. All I have been able to figure out is the total number of logins, but I can't determine how to compare if $1(user name) is there more than once, and ontop of that count it if it is.

ex.

toyoung
rasmith
toyoung

output i'm looking for would be

toyoung 2
rasmith 1

here's what i have so far:

last | awk ' END {print "Number of logins:", NR} '
# 2  
Old 04-22-2008
Code:
last | awk '{print $1}' | uniq -c

Output may not be in the format you wanted. But this will help.
# 3  
Old 04-22-2008
last | nawk -v username="username" 'BEGIN {totallogin =0 }
{ if ($1 == username) totallogin += 1 } END { print totallogin }'
# 4  
Old 04-22-2008
Updated..

Code:
last | awk '{print $1}' | uniq -c | awk '{print $2 " logged in " $1 " times"}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding which is Running number

Hi All, I have a list of data in the listing file and I run row by row to process the record, but how to identify what is the current process line number ? Thanks. (2 Replies)
Discussion started by: ckwan
2 Replies

2. UNIX for Dummies Questions & Answers

Help on finding a number

Hello, Here is my question. I have a file which contains the html values. I have to find the decimal number from it. It is tagged around >68.74<. Please help me on it.. alt='' ><\/td>\n\t\t<td align=\"right\" class='data_table_text data_table_conv_averages_text' \ style='padding-right:... (1 Reply)
Discussion started by: sathyaonnuix
1 Replies

3. Shell Programming and Scripting

finding number in exact column

Dear all, I want to find a number in exact column but I don't know how to do it. Here is the thing, data is shown below, and I want to find 416 in the first column and print it out, how should I deal with it? Thank you very much! ab33 50S01S 958 279.068999 67.251013 -150.172544 67.250000... (5 Replies)
Discussion started by: handsonzhao
5 Replies

4. Shell Programming and Scripting

finding the number of dtsessions

I am trying to find out the number of dtsessions. using the command wc -l $FILE_NAME it works fine But when I try to assign this value to some variable using the command set NUM_DT_SESSION=$(wc -l $FILE_NAME) it shows error Variable syntax find below the complete command... (1 Reply)
Discussion started by: hiten.r.chauhan
1 Replies

5. Shell Programming and Scripting

Finding the line with the exact same number

Hello All, What i am doing is , i tail a file from certain chatacter and then cat -n to get the line numbers.I search for a particular string and gets it line number. What i am interested in is the next line immediately after the pattern i search. But grep gives me result for all line... (5 Replies)
Discussion started by: kailash19
5 Replies

6. Solaris

Finding server serial number

Hi All, I wnat to know how to find out the Server serial number in command prompt? I am using sneep command but it throughing unknown. Thanks and Regards, (8 Replies)
Discussion started by: lbreddy
8 Replies

7. Solaris

Finding port number !!

Hi all , I want know the port no on which a particular application is running. How to find that? Thanks in anticipation (11 Replies)
Discussion started by: kumarmani
11 Replies

8. UNIX for Dummies Questions & Answers

Number of multiple logins

How can i get the number of multiple logins of the user those are logged in currently... (1 Reply)
Discussion started by: Ramkum
1 Replies

9. Shell Programming and Scripting

Finding number ranges using grep

Is it possible for me to find numbers in a file by a range using grep? like cat data | cut -f1 | grep <info> Im trying to find information and extract every amount that is less than a number (ie less than 75 or whatever) Is this possible? (2 Replies)
Discussion started by: DKNUCKLES
2 Replies

10. Shell Programming and Scripting

finding biggest number

I think my script is working but i am trying to understand while I am tracing to see if it's realli working.. can somebody please comment.. also. is there different way to write this in shell? sh -x findbiggestnum 1 2 3 + big=0 + big=1 + big=2 + big=3 + echo 3 3 big=0 ... (3 Replies)
Discussion started by: hankooknara
3 Replies
Login or Register to Ask a Question