10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
input:
chr1 1 2 3
chr1 1 2 4
chr1 2 4 5
chr2 3 6 9
chr2 3 6 10
Code:
awk '{a+=$4}END{for (i in a) print i,a}' input
Output:
chr112 7
chr236 19
chr124 5
Desired output:
chr1 1 2 7
chr2 3 6 19
chr1 2 4 5 (1 Reply)
Discussion started by: jacobs.smith
1 Replies
2. Shell Programming and Scripting
I have an input file that looks like:
ID1 V1 ID2 V2 P1 P2 P3 P4 ..... n no. of columns
1 1 1 1 1.0000 1.0000 1.0000 1.0000
1 1 1 2 0.9999 0.8888 0.7777 0.6666
1 2 1 1 0.8888 0.7777 0.6666 0.5555
1 2 1 2 0.7777 0.6666 0.5555 0.4444
2 1 1 1 0.6666 0.5555 0.4444 0.3333
2 1 1 2 0.5555 0.4444... (4 Replies)
Discussion started by: sdp
4 Replies
3. Shell Programming and Scripting
a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg,hh,ii
a thru ii are digits and strings....
The awk needed....if coloumn 9 == i (coloumn 9 is string ), output the sum of x's(coloumn 22 ) in all records and sum of y's (coloumn 23 ) in all records in a file (records.txt).... (6 Replies)
Discussion started by: BrownBob
6 Replies
4. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
Hi guys, i'm a new guy here, and it's my first time creating a unix script.
can you guys help me out here? i'd really appreciate it. :(
Here's my problem:
This is the file i'm using, it has 6 columns, the first three columns are... (12 Replies)
Discussion started by: ramneim
12 Replies
5. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Hi guys, i'm a new guy here, and it's my first time creating a unix script.
can you guys help me out here? i'd... (3 Replies)
Discussion started by: ramneim
3 Replies
6. Shell Programming and Scripting
My file is something like this :
03.097
03.094
03.093
03.095
03.091
04.089
06.093
07.225
08.196
06.097
06.094
05.096
04.086
I'd like to sum it from a given line to another one , e.g.: from line 10 until line 20
What s the awk way solving this ? (1 Reply)
Discussion started by: firelink
1 Replies
7. Shell Programming and Scripting
Hi friends, lets assume that I have lines of data as follows
rico 12 bct 58
pot 65 vft 41
dek 45 kbt 13
her 35 ubr 14
. . . .
. . . .
. . . .
I want to calculate the sum of the numbers at the 2. row of each... (6 Replies)
Discussion started by: rpf
6 Replies
8. Shell Programming and Scripting
Basically I have to process a text file which has been sorted this way:
John 12
John 13
John 10
John 900
Peter 20
Peter 30
Peter 32
The first column is a name, and the second an arbitrary value, both delimited by a space. How can I sum them up such that it would become:
John 935... (2 Replies)
Discussion started by: Dwee
2 Replies
9. Shell Programming and Scripting
Hey,
I am gettin a bit crazy with my script. I have several input datas with the same name (5.ill) in different folders (daysim_01, daysim_02, etc.). The 4. column of each of the data has to be summed with each other and then hass to be written in one new file.
So file1:
1 1 0 1
2 1 1 2 ... (7 Replies)
Discussion started by: ergy1983
7 Replies
10. Shell Programming and Scripting
Hi All,
I have a file like -
num.txt
12, 34, 65, line1
34, 65, 89, line2
43, 65, 77, line3
I want to do two things -
1. Add first three columns of each line and print the line with largest value.
i.e. (12+34+65) for 1st line and so on.
2. Add middle column of each line i.e.... (3 Replies)
Discussion started by: asahlot
3 Replies