Reputation: 2559
I'm looking for zoom to understand why this:
palabra=s_gonzalez
i=10
awk -vvar1=$palabra -vvvar2=$i '( $1 == var1 ) && ( $2 == var2 ) {print $0}' As
is not printing anything. The As
file contains:
r_castillo 10
flores 6
s_gonzalez 10
o_gutzwiller 12
h_ji 4
Thanks in advance for any suggestion.
Upvotes: 0
Views: 155
Reputation: 212208
As a technique to avoid this sort of problem, you can assign variables without -v
. I would rewrite the command:
awk '$1==var1 && $2==var2' var1=$palabra var2=$i As
It always seems simpler to me to assign variables as arguments after the program rather than as -v
options before the program. (-v
assignments are available in the BEGIN
block, but that is irrelevant in this case.)
Upvotes: 0