Compare strings between 2 arrays and print number in AWK
Hi to everyone,
Please some help over here.
Hi have array a with 6 elements and array b with 3 elements as shown inside BEGIN{} statement.
I need help to get the correct sintax (the part in red) to compare if string from array b is in array a and print the number
related for each match.
E.g. If b[1]="Carl L" is in array a, then print
3
9
for b[2]="John M" print
7
5
and for b[3]="Mike F" print
4
8
I need to do this in awk because the loop will be part of a main awk code. In this sample only 2 occurences of b are in a,
but b values could be many times in a, so I need to print all matches for each value in b.
i'm new to awk, and i've been searching on the forum for sum of a column but all the scripts does sum a column of an entire file.
I've a file like this:
cat file.txt
1234 5678
5678 1234
I want to use awk to do sum of each column per line not entire file, compare the two then write the... (1 Reply)
I need your help to discover missing elements for each box.
In theory each box should have 4 items: ITEM01, ITEM02, ITEM08, and ITEM10.
Some boxes either have a missing item (BOX02 ITEM08) or might have da duplicate item (BOX03 ITEM02) and missing another one (BOX03 ITEM01).
file01.txt
... (2 Replies)
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Hi !
I have this input:
12{11}{11110}{80}3456
{123}15{60}9876{8083}34
I try to work on individual numbers between braces.
3 possible cases (here I used colours to be clearer only):
- there is no "0" among the characters between braces: so we don't touch anything.
- there is a "0" among... (4 Replies)
I would like to print the number of records of 2 files, and divide the two numbers
awk '{print NR}' file1 > output1
awk '{print NR}' file2 > output2
paste output1 output2 > output
awl '{print $1/$2}' output > output_2
is there a faster way? (8 Replies)
Hello,
I am trying to redirect files to a directory by using a config file. The config files is as such:
xxxxxx,ID,PathToDirectory
xxxxxx,ID2,PathToDirectory2
and so on...
I have a variable that should match one of these IDs. I want to load this config file into an awk array, and... (2 Replies)
People, I need your help with making a script which will
1. take as an input the number of lines, smth like this:
((RUBROBACTER_1_PE1288
(((SALINISPORA_1_PE1863
SALINISPORA_1_PE1828)100
((NOCARDIOIDES_2_PE2419
PROPIONIBACTERIUM_1_PE1395)96
((((((((CORYNEBACTERIUM_1_PE1119... (3 Replies)
pls help me on this... and im really sorry because i really don't know where to start here...
FILE1
ABC DEF 10 2
DEF GHI 11 3
GHI JKL 12 5
JKL MNO 13 7
MNO PQR 14 5
requirements:
1. The third string should only be 10 or 12
2. The fourth string should only be 2 or 3
3. Prinnt... (1 Reply)
Hi,
I want to print only lines in between two strings and not the strings using awk.
Eg:
OUTPUT
top 2
bottom 1
left 0
right 0
page 66
END
I want to print into a new file only
top 2
bottom 1
left 0... (4 Replies)