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

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



On Sun, Sep 16, 2012 at 4:28 PM, Christofer C. Bell
<christofer.c.bell@gmail.com> wrote:

> $ for (( i=1;i<=3;i++ )); do gawk -v var=$i 'NR == var { print}' input ; done
>
> You're asking awk to read lines from a file, so you need to give the
> file over to awk.  The above gives you the output you're looking for.
> The bash portion of your script (the loop) and the -v var portion of
> your awk command are fine.

Thanks, Chris. you've clear the dirty dust in my eyes. :)

--
Marco


Reply to: