[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[ask] awk - passing for loop bash variables to awk



Hi guys,
I get a difficulty to produce the desired output using awk. i want to
use for loop bash variable as the input to the awk variable
here is the illustrated input:

line_1
line_2
line_3
line_4
line_5
line_6
line_7
line_8
line_9
line_10

here is the desired output:
line_1
line_2
line_3

here is what i do:
cat input | for (( i=1;i<=3;i++ )); do gawk -v var=$i 'NR == var { print}'; done

but, the result is always:
line_1

i would be glad if somebody help me. Thanks.

Greetings,

Marco


Reply to: