find information about logins


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find information about logins
# 1  
Old 03-06-2010
find information about logins

Hi, all
I want to make a bash script that print all users from a system using last command.
I want to print the number of user's login in the format (descending order):

Code:
5   user1    address1
4   user2    address2


I am trying the command
Code:
last | awk '{print $1 " " $3}' | sort | uniq

but it is not run as I want


Could you help me ??

Last edited by Scott; 03-06-2010 at 02:42 PM.. Reason: Code tags
# 2  
Old 03-06-2010
MySQL

use this command

Code:
last | sed -r 's/[ \t]+/ /g'  | cut -d ' ' -f 1,3 | sort | uniq

# 3  
Old 03-06-2010
Awk version:

Code:
 last | awk '/./ {$0=++c " " $1 "  " $2}1;' | tac

# 4  
Old 03-06-2010
Thanks a lot for your quick answer.

The problem I have is that I have to count the number of logins and sort by number then.
# 5  
Old 03-06-2010
Code:
last | tr -s " " | cut -d ' ' -f 1,3 | sort | uniq

# 6  
Old 03-06-2010
Thanks for your help

I check the sort and uniq parameters and I found it.

Last edited by peter20; 03-06-2010 at 10:47 AM..
# 7  
Old 03-06-2010
This awk command might work for you:

Code:
last -d | awk '/./{print $1, $3}' | sort -n -k1 | uniq -w1 -c

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do you find max filesize with inode information ?

How do you find the maximum file size with the following information -: A unix filesystem has 1024 bytes block size with 32-bit address. The i-node has 12 direct and 1 indirect, 1 double indirect, and 1 triple indirect addresses. What is the maximum file size it can access ? What is the... (1 Reply)
Discussion started by: sreyan32
1 Replies

2. Red Hat

Command to find the harddisk information

I tried to find the harddisk information using the command hdparm -i /dev/sda. But I couldn't get the info. Is there any similar command to find the harddisk serial number. (5 Replies)
Discussion started by: gsiva
5 Replies

3. UNIX for Dummies Questions & Answers

Where to find Kernel development Information

Hi, I would like to do some research on the Linux kernel. Where can I find information about the current kernel development, who is working on the kernel. I looked up the change log on the kernels main page, but that doesn't help either. My goal is to find out where the focus of the current... (3 Replies)
Discussion started by: Learn4Life
3 Replies

4. Programming

GDB - how to find interesting information?

Hi all, I was wondering how to find interesting information inside the assembly code. As example, I've been trying something at smashthestack wargame. After viewing the assembly code via disassemble main command, I'm not sure what else to do. Hopefully someone can guide me here. This is... (2 Replies)
Discussion started by: type8code0
2 Replies

5. AIX

Find information for Host and SAN disconnect

Can someone point me in the right direction as to where I can find information on how to cleanly disconnect my AIX 5.3 host from our DS/4200 SAN. I have to do a firmware upgrade on the SAN. -Thanks (2 Replies)
Discussion started by: tfort73
2 Replies

6. Solaris

How to find user information from NIS client

Hi All, I have logged into a solaris NIS server by using NIS username and password in an clinet machine, how can i get my user details like in which group iam whats my user ID , group ID etc....... Kindly help (2 Replies)
Discussion started by: judi
2 Replies

7. Shell Programming and Scripting

Find information from complicated strings

Hi experts, I have the file with these lines: var1=thu_13:12:32,var2=Microsoft,var3=240ms,var4=Mozilla/4.0_(sun;_MSIR_3-4;_windows.;_NET_1.1323.53 var1=thu_13:13:32,var2=Microsoft,var3=213ms,var4=Mozilla/4.0_(sun;_MSIR_3-4;_windows.;_NET_1.1323.53... (9 Replies)
Discussion started by: lalelle
9 Replies

8. UNIX for Dummies Questions & Answers

How do I find route table information

I am trying to install a new AIX server and I am migrating off of an older AIX server. Does anyone have a quick and easy method for getting the static route information from the old server so I can just maybe copy a file over to the new server ? (1 Reply)
Discussion started by: Docboyeee
1 Replies

9. UNIX for Dummies Questions & Answers

How do I find information about the hardware?

Hello I used to Red Hat and the common Linux commands, but now I have to deal with a SCO-Unix (Unix Ware 7). I have to find information about the hardware. What networkcard is installed? What graphiccard is installed? Which SCSI-Adapter and what kind of harddisks? What software is... (3 Replies)
Discussion started by: Fwurm
3 Replies

10. UNIX for Dummies Questions & Answers

Please help me find out system information

I'm just getting started with unix and would like to know 1) how to tell how big the harddrive is 2) how to tell if there are multiple harddrive installed on the machine 3) a relitavely easy way to tell what programs are installed on the machine. I'm using Sun OS 5.6 Thanks (3 Replies)
Discussion started by: ViperD
3 Replies
Login or Register to Ask a Question