05-09-2011
Hi, here is a clarification:
{B[$1]} | Create an array element B[$1] . If such an element already exists then this will not create a new element, hence an element will only be created once for the value $1, irrespective of the number of occurrences of $1 (in a group of 7, see below) |
!(NR%7) | If the remainder of the line number divide by 7 equals 0 (if it is not greater than 1) then we are at a multiple of 7, so seven lines will have been read) |
for(i in B){delete B[i];A[i]++ | then for each element in B increase the count in array A and then discard the array element B[i]. Afterwards all elements in array B will have been discarded. This sequence gets repeated after every 7 lines. |
END{for(i in A)print i,A[i]} | print all the array element in array A and their values |
Hope this helps...
S.
This User Gave Thanks to Scrutinizer For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I am currently trying to edit an ldif file. The ldif specification states that a newline followed by a space indicates the subsequent line is a continuation of the line. So, in order to search and replace properly and edit the file, I open the file in textwrangler, search for "\r " and... (14 Replies)
Discussion started by: rowie718
14 Replies
2. UNIX for Dummies Questions & Answers
hi Gurus,
I'm a newbie in scripting please check my script if this is correct. I think there's something wrong with it but I;m not sure. I'm trying to create multiple lines using awk from external xml files but i want to add additonal info in the data manually
Since i don't knwo how to... (0 Replies)
Discussion started by: sexyTrojan
0 Replies
3. UNIX for Dummies Questions & Answers
I'm trying to parse a configuration text file using awk. The following is a sample from the file I'm searching. I can retrieve the formula and recipe names easily but now I want to take it one step farther. In addition to the formula name, I would like to also get the value of the attribute... (6 Replies)
Discussion started by: new2awk
6 Replies
4. UNIX for Dummies Questions & Answers
I know uniq exists, but am not sure how to remove repeating lines when they are groups of two different lines repeating themselves, without using sort. I need them to be sorted in the original order, just to remove repeats.
cd /media/AUDIO/WAVE/9780743518673/mp3
~/Desktop/mp3-to-m4b... (1 Reply)
Discussion started by: glev2005
1 Replies
5. Shell Programming and Scripting
I am sorry if I am posting in wrong thread.
Experts,
I have 2 files
File 1 File 2
line1 line1 |
line2 line2 | group 1
line3 line3 |
line1 line1 |
line2 ... (6 Replies)
Discussion started by: suraj.sheikh
6 Replies
6. Shell Programming and Scripting
I have the data like this:
PONUMBER,SUPPLIER,LINEITEM,SPLITLINE,LINEAMOUNT,CURRENCY
IR5555,Supplier1,1,1,83.1,USD
IR5555,Supplier1,1,3,40.4,USD
IR5555,Supplier1,1,6,54.1,USD
IR5555,Supplier1,1,8,75.1,USD
IR5556,Supplier2,1,1,41.1,USD
IR5556,Supplier2,1,3,43.1,USD
... (3 Replies)
Discussion started by: jeffreybsu
3 Replies
7. Shell Programming and Scripting
I have two files.
File 1 is a two-column index file, e.g.
comp11084_c0_seq6:130-468(-) comp12746_c0_seq3:140-478(+)
comp11084_c0_seq3:201-539(-) comp12746_c0_seq2:191-529(+)
File 2 is a sequence file with headers named with the same terms that populate file 1. ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
8. Shell Programming and Scripting
Hello to all,
I'm trying to print the value corresponding to the words A, B, C, D, E. These words could appear sometimes and sometimes not inside each group of lines. Each group of lines begins with "ZYX".
My issue with current code is that should print values for 3 groups and only is... (6 Replies)
Discussion started by: Ophiuchus
6 Replies
9. Shell Programming and Scripting
Hi, I have some data I have taken from the internet in the following scheme:
name
direction
webpage
phone number
open hours
menu url
book url
name
...
Of course the only line that is mandatory is the name wich is the one I want to sort by.
I have the following sed & awk script that... (3 Replies)
Discussion started by: devmsv
3 Replies
10. Shell Programming and Scripting
I have three files as an input and I need to rearrange this input to match the rules by which the processing program consumes the data.
My files are:
/tmp$ cat F
# file -1-
FS00|0|zero-zero|
FSTA|0|10|
FSTA|0|12|
FSTA|0|15|
FSTA|0|17|
FS00|3|negative|
FSTA|3|-1|
FS00|5|regular|... (2 Replies)
Discussion started by: migurus
2 Replies