awk line with two conditions

Hi there,

I wanna define a variable 'tempbase'. Therefore I read a text file "base.out". "base.out" contains a list with four columns. 'tempbase' is the 4th entry in the line, where the first entry is equal to the predefined variable $orb1 and the second entry is equal to $orb2. I wrote the code below, but it doesn't work:

set tempbase = `awk '$1 == "$orb1" && $2 == "$orb2" {print $4}' ../base.out`

Can anyone help out?
Thank you!

set tempbase = `awk -vx="$orb1" -vy="$orb2" '$1==x && $2==y  {print $4}' ../base.out`
1 Like
orb1=`awk '{print $1}' baseout`; orb2=`awk '{print $2}' baseout`; tempbase=`awk '{print $4}' baseout`; echo $orb1; echo $orb2; echo $tempbase;

$1 gives you the first entry of file baseout and it gets stored in $orb1
$2 gives you the second entry of file baseout and it gets stored in $orb2
$4 gives you the forth entry of the file baseout and it gets stored in $tempbase