Sponsored Content
Top Forums Shell Programming and Scripting Sorting user by last login an count Post 302624961 by karghum on Tuesday 17th of April 2012 06:39:47 AM
Old 04-17-2012
Sorting user by last login an count

Experts need your help

i need to create a script which will give count of users logged between yesterday and today (Or if run exacle 12:00AM midnight, it will give count of of users logged on that day
here is how the data looks
Code:
Pappu, Paul|22-Feb-201|0|30-Jun-201
Aloor, Shiva|10-Apr-201|0|18-Aug-201
Singh, Anil|16-Mar-201|0|10-Nov-201
Sun, Henry|09-Apr-201|0|05-Sep-201
Proxy,ETS|10-Apr-201|0|08-Mar-201
Patel, Rishi|11-Feb-201|0|27-Jun-201
Dubey, Anand|16-Apr-201|0|13-Mar-201
Tiwari, Shirish|19-Feb-201|0|13-Dec-201
Vinayagam, Deiva|15-Feb-201|0|04-Jul-201
infodba_ie|28-Feb-201|0|02-Dec-201
Murugesan, Gokul|03-Apr-201|0|07-Dec-201
cntestuser|21-Mar-201|0|08-Nov-201
Gupta, Rajiv|02-Apr-201|0|27-Jun-201
Airmal, Shiva Kumar|16-Apr-201|0|09-Dec-201
Joshi, Deepak|16-Apr-201|0|17-Sep-201
Wang,Charles|10-Apr-201|0|08-Nov-201


i use awk to get last column
Code:
cat user.txt |awk -F"|" '{print $2}'`

now my output is
Code:
22-Feb-201
10-Apr-2012
16-Mar-2012
09-Apr-2012
10-Apr-2012
11-Feb-2012
16-Apr-2012
19-Feb-2012
15-Feb-2012
28-Feb-2012
03-Apr-2012
21-Mar-2012
02-Apr-2012
16-Apr-2012
16-Apr-2012
10-Apr-20122
24-Jan-2012
09-Mar-2012
16-Apr-2012
27-Feb-2012
21-Mar-2012
13-Feb-2012
03-Apr-2012
06-Mar-201

My challenge is
1- I need to sort based on month and date
2- Get a list of user logged (system time -1), mean if execute and 12-05 midnight it will give user logged yesterday
3. get the count of the rows in column 2

Please help


Moderator's Comments:
Mod Comment Please use code tags, thanks!


---------- Post updated at 05:39 AM ---------- Previous update was at 04:27 AM ----------

I was able to sort it now using sort -t '-' -k 3.1n,3.2 -k 2.1M,2.3 -k 1.1n,1.2
Code:
24-Jan-2012
11-Feb-2012
13-Feb-2012
15-Feb-2012
19-Feb-2012
22-Feb-2012
27-Feb-2012
28-Feb-2012
06-Mar-2012
09-Mar-2012
16-Mar-2012
21-Mar-2012
21-Mar-2012
02-Apr-2012
03-Apr-2012
03-Apr-2012
09-Apr-2012
10-Apr-2012
10-Apr-2012
10-Apr-2012
16-Apr-2012
16-Apr-2012
16-Apr-2012

If i get tip to get user count of yesterday's assuming i execute this 1 minute after midnight

Last edited by zaxxon; 04-17-2012 at 06:39 AM.. Reason: code tags, not html tags and also tag the code please, ty. See PM.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sorting using count, grep and count

Hi, I trying to sort information in a file by making count for every object. For example: A B A D A B C i would like to sort out count for each object (A's, B's and etc) but in actual case i dont know the object but i know the position ofthe object. do i need to use array as well? Any... (2 Replies)
Discussion started by: sukhpal_78
2 Replies

2. Shell Programming and Scripting

help about user sorting

Hi Folks, I need help in script idea, i have 5 users and there home directories are /home/user1 /home/user2 /home/user3 /home/user4 /home/user5 /home/user5 In each user there is a file xyz.txt and abcd.txt. I have two objectives. 1. sort those user have xyz.txt and abcd.txt not... (2 Replies)
Discussion started by: learnbash
2 Replies

3. Solaris

error message rmclomv ... SC Login Failure for user Please login:

Hello World ~ HW : SUN Fire V240 OS : Solaris 8 Error message prompts 'rmclomv ... SC login failure ...' on terminal. and Error Message prompts continually 'SC Login Failure for user Please login:' on Single Mode(init S) The System is in normal operation, though In case of rain, Can... (1 Reply)
Discussion started by: lifegeek
1 Replies

4. Shell Programming and Scripting

Uniq sorting and count

Hi Unix gurus, I have a requirement where I need to find the file count based on unique file names. OPEN_INV_MMDDYYYY_HHMM.xls OPEN_INV_MMDDYYYY_HHMM.xls OPEN_INV_MMDDYYYY_HHMM.xls CLOSE_INV_MMDDYYYY_HHMM.xls CLOSE_INV_MMDDYYYY_HHMM.xls OPEN_INV_MMDDYYYY_HHMM.txt... (2 Replies)
Discussion started by: shankar1dada
2 Replies

5. AIX

Clear failed login count

What's actually the difference between these two command: 1) chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s username 2) chuser unsuccessful_login_count=0 username Are there any impact on executing either one of those command to clear/reset the failed login count in AIX?... (2 Replies)
Discussion started by: ph4nt0m227
2 Replies

6. Solaris

Reset failed login count

Hi, Can someone tell me the command to do this in solaris 5.10 please? I've trawled around the internet for ages but all I can find is the AIX command... Thanks (2 Replies)
Discussion started by: Grueben
2 Replies

7. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

8. AIX

User Account Login Login on your AIX server

I want to learn AIX. I would like to find someone who would be willing to give me a login to their AIX home lab server. My intent is to poke around and discover the similarities and differences of AIX compared to other *NIXs. I am a UNIX admin so I can think of what some immediate concerns may... (1 Reply)
Discussion started by: perl_in_my_shel
1 Replies

9. Shell Programming and Scripting

Count occurences of a character in a file by sorting results

Hello, I try to sort results of occurences in an array by using awk but I can't find the right command. that's why I'm asking your help ! :) Please see below the command that I run: awk '{ for ( i=1; i<=length; i++ ) arr++ }END{ for ( i in arr ) { print i, arr } }' dictionnary.txt ... (3 Replies)
Discussion started by: destin45
3 Replies
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy