Sponsored Content
Full Discussion: Sort uniq or awk
Top Forums Shell Programming and Scripting Sort uniq or awk Post 302757105 by RudiC on Thursday 17th of January 2013 05:08:06 AM
Old 01-17-2013
Making wild guesses that the requestor wants any possible combination of field 2 and field 5 in a large comma separated file of numbers, I get at
Code:
$ awk  'BEGIN {SUBSEP=":"}
         NR==1 {next}
         {IP1[$2]++;PORT2[$2,$5]++}
         END {for (i in PORT2) {x=index(i,SUBSEP); j=substr(i,1,x-1); print "IP1=" j ": " IP1[j] ", PORT2=" substr(i,x+1)":  "PORT2[i]}}
        ' FS="," file
IP1=1: 1, PORT2=5:  1
IP1=2: 2, PORT2=5:  1
IP1=2: 2, PORT2=6:  1
IP1=3: 3, PORT2=5:  2
IP1=3: 3, PORT2=6:  1

Input file would be sth like
Code:
datetime,ip1,port1,ip2,port2,number
9,1,8,7,5,4 
9,2,8,7,5,4
9,3,8,7,5,4
9,3,8,7,5,4
9,2,8,7,6,4
9,3,8,7,6,4

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sort/uniq

I have a file: Fred Fred Fred Jim Fred Jim Jim If sort is executed on the listed file, shouldn't the output be?: Fred Fred Fred Fred Jim Jim Jim (3 Replies)
Discussion started by: jimmyflip
3 Replies

2. Shell Programming and Scripting

Sort, Uniq, Duplicates

Input File is : ------------- 25060008,0040,03, 25136437,0030,03, 25069457,0040,02, 80303438,0014,03,1st 80321837,0009,03,1st 80321977,0009,03,1st 80341345,0007,03,1st 84176527,0047,03,1st 84176527,0047,03, 20000735,0018,03,1st 25060008,0040,03, I am using the following in the script... (5 Replies)
Discussion started by: Amruta Pitkar
5 Replies

3. Shell Programming and Scripting

Help with Uniq and sort

The key is first field i want only uniq record for the first field in file. I want the output as or output as Appreciate help on this (4 Replies)
Discussion started by: pinnacle
4 Replies

4. Shell Programming and Scripting

sort | uniq question

Hello, I have a large data file: 1234 8888 bbb 2745 8888 bbb 9489 8888 bbb 1234 8888 aaa 4838 8888 aaa 3977 8888 aaa I need to remove duplicate lines (where the first column is the duplicate). I have been using: sort file.txt | uniq -w4 > newfile.txt However, it seems to keep the... (11 Replies)
Discussion started by: palex
11 Replies

5. Shell Programming and Scripting

Text Proccessing with sort,uniq,awk

Hello, I have a log file with the following input: X , ID , Date, Time, Y 01,01368,2010-12-02,09:07:00,Pass 01,01368,2010-12-02,10:54:00,Pass 01,01368,2010-12-02,13:07:04,Pass 01,01368,2010-12-02,18:54:01,Pass 01,01368,2010-12-03,09:02:00,Pass 01,01368,2010-12-03,13:53:00,Pass... (12 Replies)
Discussion started by: rollyah
12 Replies

6. Shell Programming and Scripting

Sort and uniq after comparision

Hi All, I have a text file with the format shown below. Some of the records are duplicated with the only exception being date (Field 15). I want to compare all duplicate records using subscriber number (field 7) and keep only those records with greater date. ... (1 Reply)
Discussion started by: nua7
1 Replies

7. Shell Programming and Scripting

Sort field and uniq

I have a flatfile A.txt 2012/12/04 14:06:07 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:07:22 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 17:13:27 |trees|Boards 2, 3|denver|mekong|mekong12 2012/12/04 14:07:39 |rain|Boards 1|tampa|merced|merced11 How do i sort and get... (3 Replies)
Discussion started by: sabercats
3 Replies

8. Shell Programming and Scripting

Uniq or sort -u or similar only between { }

Hi ! I am trying to remove doubbled entrys in a textfile only between delimiters. Like that example but i dont know how to do that with sort or similar. input: { aaa aaa } { aaa aaa } output: { aaa } { (8 Replies)
Discussion started by: fugitivus
8 Replies

9. UNIX for Dummies Questions & Answers

Uniq and sort -u

Hello all, Need to pick your brains, I have a 10Gb file where each row is a name, I am expecting about 50 names in total. So there are a lot of repetitions in clusters. So I want to do a sort -u file Will it be considerably faster or slower to use a uniq before piping it to sort... (3 Replies)
Discussion started by: senhia83
3 Replies

10. Shell Programming and Scripting

Sort & Uniq -u

Hi All, Below the actual file which i like to sort and Uniq -u /opt/oracle/work/Antony/Shell_Script> cat emp.1st 2233|a.k. shukula |g.m. |sales |12/12/52 |6000 1006|chanchal singhvi |director |sales |03/09/38 |6700... (8 Replies)
Discussion started by: Antony Ankrose
8 Replies
MHEARDD(8)						     Linux Programmer's Manual							MHEARDD(8)

NAME
mheardd - collect information about packet activity SYNOPSIS
mheardd [-f] [-l] [-n number] [-p [!]port1[,port2,..]] [-v] DESCRIPTION
Mheardd is a daemon that collects the statistics about the activity on all the AX.25 channels that are configured. The list generated is available for viewing by the mheard(1) program. The information collected is a superset of the information normally collected by similar mheard programs and this is reflected in the options available for the viewing program. Logging to the system log file may be enabled which will enable monitoring of pathalogical conditions, for example invalid frame types and invalid/unknown protocol IDs. OPTIONS
-f Deletes the existing mheard logging file at program startup, this is not the default. -l Enables logging to the system log file. The default is off. -n number Sets the number of entries in the activity list file, the default is 100. The minimum value allowed is 10 and the maximum is 1000. -p [!]port1[,port2,..] With -p, you instruct mheardd to only listen on specified ax25 ports. You may give more ports, seperated by ','. If you intro- duce the port(s) by a leading '!', then mheardd will listen on all ports except those you specified. -v Display the version. FILES
/var/ax25/mheard/mheard.dat /etc/ax25/axports SEE ALSO
mheard(1), ax25(4). AUTHOR
Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk> Linux 27 August 1996 MHEARDD(8)
All times are GMT -4. The time now is 01:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy