Advanced: Sort, count data in column, append file name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Advanced: Sort, count data in column, append file name
# 15  
Old 08-14-2012
Thanks Raj.

After a lot of testing (I know close to nothing about Linux/Unix/awk) I managed to make some modifications to the script:
Code:
awk 'BEGIN{i=1}{
            x=$1;
            y=$5":"$6
            p="chromosome"$7"-""chromosome"$9;
            if(!match(c[y],x))
                {
                    if(c[y])
                        {
                            c[y]=substr(c[y],1)","substr(x,1)
                        }
                    else
                        {
                            c[y]=p" "x
                };
                    
                };
            if(a[y])
                {
                    a[y]++
                }
            else
                {
                    a[y]=1;
                    b[i]=y;
                    i++
                }
        }
 END{for(k=1;k<i;k++){split(b[k],d,":");print a[b[k]],d[1],d[2],c[b[k]]}}'

These modifications enabled me to extract other columns of interest and add them to the output file. I am now so excited that I want to learn more. Each time I hit "enter" on my keyboard and see a new line knowing that the script has been run within milliseconds - I just get so impressed. Thanks for all the help, you have recruited a Windows user to shell programming and scripting in Linux. Awk awk Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append data with substring of nth column fields using awk

Hi guys, I have problem to append new data at the end of each line of the files where it takes whole value of the nth column. My expected result i just want to take a specific value only. This new data is based on substring of 11th, 12th 13th column that has comma seperated value. My code: awk... (4 Replies)
Discussion started by: null7
4 Replies

2. Shell Programming and Scripting

Help with sort only column 2 data separately

Input File Contig_1_294435nt 242231 242751 Contig_1_294435nt 242390 242782 Contig_1_294435nt 242390 242782 Contig_1_294435nt 291578 291668 Contig_2_242278nt 75910 76271 Contig_2_242278nt 76036 76316 Contig_2_242278nt 76036 76316... (2 Replies)
Discussion started by: perl_beginner
2 Replies

3. Shell Programming and Scripting

To append new data at the end of each line based on substring of last column

Hi guys, I need to append new data at the end of each line of the files. This new data is based on substring (3rd fields) of last column. Input file xxx.csv: U1234|1-5X|orange|1-5X|Act|1-5X|0.1 /sac/orange 12345 0 U5678|1-7X|grape|1-7X|Act|1-7X|0.1 /sac/grape 5678 0... (5 Replies)
Discussion started by: null7
5 Replies

4. Shell Programming and Scripting

Append data to first column delimited file

Hi, I have a data like Input: 12||34|56|78 Output: XYZ|12||34|56|78 I tried like this , but it puts it on another line awk -F "|" ' BEGIN {"XYZ"} {print $0} 'file Any quick suggessitons in sed/awk ? am using HP-UX (3 Replies)
Discussion started by: selvankj
3 Replies

5. Shell Programming and Scripting

Count column data in a text file

I have a text file that has the following column data: 0.007 0.005 0.004 0.007 How do i output the total sum of the data above? (6 Replies)
Discussion started by: alegnagrp
6 Replies

6. Shell Programming and Scripting

Count column data

Hi Guys, B07 U51C A1 44 B1 44 Yes B07 L64U A2 44 B1 44 Yes B07 L62U A2 44 B1 44 Yes B07 L11C A4 32 B1 44 NO B05 L12Z A1 12 B1 44 NO B01 651Z A2 44 B1 44 NO B04 A51Z A2 12 B1 44 NO L07 B08D A4 12 B1 44 NO B07 RU8D A4 44 B1 44 Yes B07 L58D A4 15 B1 44 No B07 LA8D A4 44 B1 44 Yes B07... (6 Replies)
Discussion started by: asavaliya
6 Replies

7. Shell Programming and Scripting

Sort data As per first Column

hI I have file A NSU30504 5 6 G 6 NSU3050B T 7 9 J NSU30506 T I 8 9 NSU3050C H J K L Output: NSU3050B T 7 9 J NSU3050C H J K L NSU30504 5 6 G 6 NSU30506 T I 8 9Video tutorial on how to use code tags in The UNIX and Linux Forums. (13 Replies)
Discussion started by: pareshkp
13 Replies

8. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

9. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

10. Shell Programming and Scripting

Append the data to first column

Hi, The below is the content of the file. 008.03.50.21|ID4|0015a3f01cf3 008.04.20.16|ID3|0015a3f02337 008.04.20.17|ID4_1xVoice|00131180d80e 008.04.20.03|ID3_1xVoice|0015a3694125 008.04.30.05|ID3_1xVoice|0015a3f038af 008.06.30.17|ID3_1xVoice|00159660d454... (2 Replies)
Discussion started by: ravi_rn
2 Replies
Login or Register to Ask a Question
RECVSTATS(8C)															     RECVSTATS(8C)

NAME
recvstats - summarize HylaFAX receive accounting information SYNOPSIS
/usr/sbin/recvstats [ options ] [ files ] DESCRIPTION
recvstats is a command script that prints a summary of the HylaFAX accounting statistics for received facsimile. The statistics can be sorted using one of several keys: the caller's CSI (default), CIDName (CallID2), CIDNumber (CallID1), the communication speed, or the com- munication data format. Statistics are read from the file /var/spool/fax/etc/xferfaxlog unless filenames are specified on the command line. The following table is an example of the output from recvstats (using the default sort key): Sender CIDName CIDNumber Pages Time Pg/min Errs TypRate TypData 61 30:47 2.0 16 9600 1-DMR +13037904674 5 1:34 3.2 2 9600 1-DMH +14159657824 1 1:00 1.0 0 9600 1-DMH +15086636852 2 0:00 2.0 0 9600 1-DMH +15105268781 740 5:47:51 2.1 59 9600 1-DMH +15105287164 20 7:00 2.9 0 9600 1-DMH +15123713545 3 1:19 2.3 0 9600 1-DMH +15123713641 5 1:04 4.6 0 9600 1-DMH +16099211926 3 2:00 1.5 0 9600 1-DMH +17088987617 1 0:18 3.3 0 9600 1-DMH 415 390 6175 22 6:01 3.6 0 9600 1-DMH 415 965 7651 56 34:52 1.6 14 9600 1-DMH 415 973 6723 1 2:09 0.5 0 9600 2-DMR 49 211 161514 1 0:00 1.0 0 9600 2-DMR 8185970503 1 0:28 2.1 0 9600 2-DMR ALDUS CORPORATION ALDUS CO 5551212 3 2:34 1.2 0 9600 1-DMH -------------------------------------------------------------------------------------------------- Total 925 7:19:03 2.1 91 The Sender column shows the caller's TSI (notice that some callers have not setup a TSI). The CIDName column is the received CIDName value for the sender. The CIDNumber column is the received CIDNumber value for the sender. The Pages column is the total number of good pages received. The time column shows the total amount of time spent receiving facsimile from a sender. The Pg/min column displays the average transfer rate. The Errs column indicates how many protocol errors were encountered while receiving facsimile. The TypRate column displays the most common communication speed with which facsimile were received. The TypData column shows the most common data format in which fac- simile data were received. OPTIONS
-age days Show information only for the facsimile received in the last specified number of days. -csi* Sort output by caller's CSI. -cidname Sort output by CIDName -cidnumber Sort output by CIDNumber -format Sort output by data format. -send* Sort output by sender (i.e. caller's CSI). -speed Sort output by signalling rate. -since time Show information only for the facsimile received since the specified time; where time is of the form ``MM/DD/YY HH:MM'' (the date(1) format string %D %H:%M). -end time Show information only for the facsimile received before the specified time; where time is of the same form as since. FILES
/var/spool/fax spooling area /var/spool/fax/etc/xferfaxlog default file from which to read statistics SEE ALSO
faxq(8C), xferfaxstats(8C), hylafax-log(5F) March 3, 1995 RECVSTATS(8C)