shell - match awk column value to a column in another file -


i need know if can match awk value while inside piped command. below:

  somebinarygivingoutputtostdout |  grep -a3 "sometext" | grep "somemoretext" | awk -f '[:|]' 'begin{ofs=","; print "col1,col2,col3,col4"}{print $4,$6,$4*10^10+$6,$8}' 

from here need check if computed value $4*10^10+$6 present (matches to) in of column value of file. if present print, else move forward.

file value needs matched below:

a,b,c,d,e 1,2,30000000000,3,4 

i need match 3rd column of above file.

i ideally in same command, because if check not applied, prints more 100 million rows (and large file).

i have read this question.

adding more info: breaking command parts part1-command:

 somebinarygivingoutputtostdout |  grep -a3 "sometext" | grep "something:" 

part1-output(just showing 1 iteration output):

something:38|something1:1|something2:10588429|something3:1491539456372358463 

part2-command use awk

awk -f '[:|]' 'begin{ofs=","; print "col1,col2,col3,col4"}{print $4,$6,$4*10^10+$6,$8}' 

part2-command output: below values printed (see how multiplied 1*10^10+10588429 , got 10010588429

1,10588429,10010588429,1491539456372358463 3,12394810,30012394810,1491539456372359082 1,10588430,10010588430,1491539456372366413 

now here need put check (within command [near awk]) print if 10010588429 present in file (say another_file.csv below)

another_file.csv a,b,c,d,e 1,2, 10010588429,4,5 x,y,z,z,k 10,20, 10010588430,40,50 

output should

1,10588429,10010588429,1491539456372358463 1,10588430,10010588430,1491539456372366413 

so every row of awk check entry in file2 column c

using associative array approach in previous question, include hyphen in place of first file direct awk input stream.

example:

grep -a3 "sometext" | grep "somemoretext" | awk -f '[:|]'     'begin{ofs=","; print "col1,col2,col3,col4"}       nr==fnr {          query[$4*10^10+$6]=$4*10^10+$6;            out[$4*10^10+$6]=$4 fs $6 fs $4*10^10+$6 fs $8;           next      }       query[$3]==$3 {          print out[$3]      }' - another_file.csv > output.csv 

more info on merging process in answer cited in question:

using awk process input multiple files


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -