Results 1 to 3 of 3
Hi! I'm new in scripting and I need some help with one simple script. I have to write a program that shows in a predetermined period (using "last" command), to ...
- 10-26-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 3
bash script for showing last users
Hi! I'm new in scripting and I need some help with one simple script. I have to write a program that shows in a predetermined period (using "last" command), to draw up a list of users who have used the machine during this period. Each user to indicate how many sessions it has been during this period. Output must be sorted alphabetically by usernames (increasing alphabetically). Can someone help
- 10-26-2009 #2Just Joined!
- Join Date
- Oct 2009
- Posts
- 3
last users
The code should be something like:
cat lastfile | cut -c1-8 | egrep -v '(^reboot)|(^$)|(^wtmp a)|(^ftp)' | sort | uniq -c | sort -rn
But how to I predetermine the period and sort alphabetically(increasing)?
- 10-27-2009 #3Just Joined!
- Join Date
- Oct 2009
- Posts
- 3
Re:
I understand that id I want to sort by user name then
number means the field to sort. So now I have only some code but still nos script:Code:sort -k 2
Script should show something like this:Code:cat lastfile | cut -c1-8 | egrep -v '(^reboot)|(^$)|(^wtmp a)|(^ftp)' | sort | uniq -c | sort -k 2
Code:Example:\\>users.sh Oct 26 11:00 - Oct 27 14.00 SESSIONS USER LAST LOGIN 12 userA Tue Oct 27 13:45 - 13:50 (00:04) 3 userB Tue Oct 27 13:31 still logged in 5 userC Tue Oct 27 13:31 still logged in ... ....... ............................................


Reply With Quote