Get values from 2 files - Complex "for loop and if" awk problem
Hi everyone,
I've been thinking and trying/changing all day long the below code, maybe some awk expert could help me to fix the for loop I've thought,
I think I'm very close to the correct output.
file1 is: file2 is:
My code so far is:
The for loop intends to generate the blocks 2, 3...N of the output (in the sample only blocks 2 y 3). The blocks 2 and 3 represents info from
uniques fruits in file1 and their respective values. Block 2 is for Apples and contains its values from file1 (8 and 12); Block 3 is for
Grapes and contains its values from file1 (4 and 7).
- In alphabetical order, Apples goes first than Grapes, then, block 2 is for Apples and block 3 for Grapes.
- For each fruit block, the fruit values must appear in same order that appear in file1, e.g for Apples 8 and 12 and not 12 and 8.
I'm getting this output:
and the correct output should be:
The first line for each block is line number from file2, e.g. Apples appears in line 13 in file2 and Grapes appear in line 14.
Maybe someone could fix my for loop, I'm stuck in the part to print in correct order the values related to each fruit block.
PS: I have another for loop that generates the first block (not shown), so it will be great if the solution could be added to the first loop.
Many thanks in advance.
Last edited by Ophiuchus; 10-21-2011 at 06:07 AM..
Hi,
i'm programming on /bin/csh and i need to get the number extracted by this:
set ppl_kn = $(awk '{ field = $6 } ; END{ print field }' < ppl_LM_kn.ppl )
and the output is: "Illegal variable name."
Please anyone can help me what's wrong?
Thanks in advance (2 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Hi,
I have a problem with "for" and "while" loop in "sh".
I have:
#!/bin/sh
for i in $(seq 1 500000); do
echo $i
doneand it's working in sh on my ubuntu, but when I try to run this on unix(I have access to my university's unix) it crash:
syntax error at line 2: `$' unexpected...... (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
I have a CSV file as shown below
"1","SANTHA","KUMAR","SAM,MILLER","DEVELOPER","81,INDIA"
"2","KAPIL","DHAMI","ECO SPORT","DEVELOPER","82,INDIA"
File is comma delimited.All the field values are enclosed by double quotes. But while using awk or cut, it interprets the comma which is present in... (6 Replies)
Hi Team. I am trying to execute a simple for loop within an awk but its giving a different result. Below is the main code:
awk '{for(i=1;i<=6;i++) print $i}'The result should be 1 2 3 4 5 6 but its not giving this result. Can someone please help? (3 Replies)
I am hoping to pull multiple strings from one file and use them to search within a block of text within another file.
File 1PS001,001 HLK
PS002,004 MWQ
PS004,002 RXM
PS004,006 DBX
PS004,006 SBR
PS005,007 ML
PS005,009 DBR
PS005,011 MR
PS005,012 SBR
PS006,003 RXM
PS006,003 >SJ
PS006,010... (11 Replies)