![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sorting your data with msort | iBot | UNIX and Linux RSS News | 0 | 05-19-2008 12:20 PM |
| Sorting data and place them in different folders | Vinaykumar1 | UNIX for Dummies Questions & Answers | 29 | 05-14-2008 09:47 AM |
| sorting data using array in ksh | ali560045 | Shell Programming and Scripting | 4 | 12-04-2007 04:26 AM |
| Sorting blocks of data | alfredo123 | Shell Programming and Scripting | 8 | 07-05-2007 11:53 AM |
| Newbie Awk data sorting | i_am_a_robot | Shell Programming and Scripting | 5 | 05-04-2007 08:33 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
It can sometimes be difficult to "imagine" what your output looks like. Thus, examples are always a good way to convey the requirments. Does this code: Code:
who | tr -s " " | cut -d" " -f1,6 | sort | uniq -c provide you with count username ip_address? If so, it may be the start of your process. Last edited by joeyg; 06-16-2008 at 01:03 PM.. Reason: added sample code line |
|
|||||
|
Here is a snippet of who | sort -uk6.2,6 :
# who | sort -uk6.2,6 bhb tty11 Jun 16 11:06 rf1 pts/67 Jun 16 10:21 (10.203.32.105) rf1 pts/20 Jun 16 10:58 (10.203.32.109) bhb pts/4 Jun 16 06:24 (10.203.32.110) rf1 pts/28 Jun 16 09:54 (10.203.32.117) bhb pts/63 Jun 16 09:00 (10.203.32.123) rf1 pts/9 Jun 16 09:42 (10.203.32.124) bhb pts/50 Jun 16 09:26 (10.203.32.126) root pts/54 Jun 16 08:30 (10.203.32.132) bhb pts/25 Jun 16 07:21 (10.203.32.151) bhb pts/10 Jun 16 10:49 (10.203.32.152) bhb pts/35 Jun 16 07:40 (10.203.32.157) bhb pts/2 Jun 16 10:47 (10.203.32.159) bhb pts/23 Jun 16 07:20 (10.203.32.163) bhb pts/26 Jun 16 07:22 (10.203.32.171) bhb pts/1 Jun 16 06:26 (10.203.32.172) bhb pts/41 Jun 16 07:53 (10.203.32.173) bhb pts/27 Jun 16 11:13 (10.203.32.183) bhb pts/21 Jun 16 10:28 (10.236.1.131) bhb pts/24 Jun 16 11:54 (10.236.32.93) bhb pts/42 Jun 16 09:24 (10.238.0.148) bhb pts/39 Jun 16 07:52 (10.238.1.29) bhb pts/31 Jun 16 10:34 (10.238.1.42) here is a snippet of who | sort -k6.2,6 : # who | sort -k6.2,6 bhb tty11 Jun 16 11:06 bhb tty14 Jun 16 09:44 bhb tty17 Jun 16 09:47 bhb tty37 Jun 16 08:25 bhb tty49 Jun 16 09:21 bhb tty8 Jun 16 07:54 root tty1 Jun 16 08:18 rf1 pts/67 Jun 16 10:21 (10.203.32.105) rf1 pts/20 Jun 16 10:58 (10.203.32.109) bhb pts/4 Jun 16 06:24 (10.203.32.110) rf1 pts/28 Jun 16 09:54 (10.203.32.117) bhb pts/63 Jun 16 09:00 (10.203.32.123) rf1 pts/9 Jun 16 09:42 (10.203.32.124) bhb pts/50 Jun 16 09:26 (10.203.32.126) root pts/54 Jun 16 08:30 (10.203.32.132) bhb pts/25 Jun 16 07:21 (10.203.32.151) bhb pts/10 Jun 16 10:49 (10.203.32.152) bhb pts/35 Jun 16 07:40 (10.203.32.157) bhb pts/2 Jun 16 10:47 (10.203.32.159) bhb pts/23 Jun 16 07:20 (10.203.32.163) bhb pts/26 Jun 16 07:22 (10.203.32.171) bhb pts/1 Jun 16 06:26 (10.203.32.172) bhb pts/41 Jun 16 07:53 (10.203.32.173) (un)fortunately, I have killed all the duplicate sessions, so none are showing up in my examples. To get really lazy, is there a way to ONLY show the duplicate IPs? |
|
||||
|
Quote:
Code:
who | \
sort -k6.2 | \
awk '{
if (x[$6]++) {
if (prev)
printf("%-8s %s\n", prev, $6)
printf("%-8s %s\n", $2, $6)
prev=""
} else
prev = $2
}'
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|