Morning Star [2012-09-16 15:44:05 +0700] wrote:

> 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:

> 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

Maybe not what you are asking for but one can get the desired output
with these:

    $ awk 'NR >= 1 && NR <= 3 { print }' inputfile

    $ head -n3 inputfile

    $ sed -n 1,3p inputfile


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/874nmytkk9....@mithlond.arda

Reply via email to