Hello folks, having a new problem with an old solution I previously had working, but think i'm missing something here.
File1:
File2:
This is my code I am trying to use:
What I am trying to do is match fields 1,2 of File1 against fields 3,7 of File2, and print all of File1 fields, and fields 4,5 of File2 only. However, what I am getting is only fields 4,5 out of File2 with space as a field separator.
Big problem #1: You are using "field 7" in the 'NR==FNR' code block which gets run for file 1 only -- that file has no "field 7". All that code block should be doing is loading file 1, it knows nothing about file 2 yet.
The other code block deals with the contents of file 2. What it's supposed to do is retrieve the matching contents of the array and print it all like you wanted.
Big problem #2: You are assigning A[$1], then assigning A[$2], then expecting output in A[$1,$2,$3]. Doesn't work that way. If you set A["stuff"] to 3, then A["else"] to 4, A["stuff","else"] won't get you anything sensible.
This is because "stuff","else" just becomes a string -- "stuff" SUBSEP "else", where SUBSEP is a special variable which is usually some odd nonprinting ASCII character. This lets awk pretend to have multidimensional arrays while actually just keeping a single index.
So:
Oh, and -v OFS="|" controlls what print "A","B","C" does. By default it would print "A B C". By setting it to | it prints "A|B|C".
hi guys,
i need help
I need to join file2 to file1 when column 3 in my file1 and column 1 in my file2 in the same string
file1
AA|RR|ESKIM
RE|DD|RED
WE|WW|SUPSS
file2
ESKIM|ES
SUPSS|SS
Output
AA|RR|ESKIM|ES
RE|DD|RED|
WE|WW|SUPSS|SS (3 Replies)
Here is my select that I have to identify the child records that are Open (e.c7 < 6000) when the parent (t2068) c.c7 > 3
SELECT c.c1000000161,
c.c7,
c.c1000000019,
e.c1000000829
FROM
t2068 c INNER JOIN t1533 e ON e.c1000000829 = c.c301572100
where
c.c7 > 3... (2 Replies)
I have file input
file1
1/1/2013 A 553.0763397 96 16582
1/1/2013 B 459.8333588 195 11992
1/2/2013 A 844.2973022 306 19555
1/2/2013 B 833.9300537 457 20165
1/3/2013 A 563.6917419 396 13879
1/3/2013 B 632.0749969 169 ... (1 Reply)
Hi,
I have a problem where I need to make this input:
nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a
nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b
look like this output:
nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Hi,
I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column).
I want to write a script to join the files by the first common column so that in the... (5 Replies)
Hi,
I'm trying to compare the first column of two files (tab or whitespace delimited, either way's fine, I`ve got both) and print the lines that are identical for the first column of both files. Something like this:
File1
AAA 26 49 7 27 36 33 46 75 73 69
AAAAA 4 10 4 7 10 18 21... (2 Replies)
Hello,
Did anyone know how to write a perl script to merge the multi-line into a single line where each line with start at timestamp
Input-->
timestamp=2009-11-10-04.55.20.829347;
a;
b;
c;
timestamp=2009-11-10-04.55.20.829347;
aa;
bb;
cc; (5 Replies)
Hi
Fields in Files 1,2,3,4 are pipe"|" separated.
Say I want to grep
col1 from File1
col3 from File2
col4 from File3
and print to File4 in the following order:
col3|col1|col4
what is the best way of doing this?
Thanks (2 Replies)