On Mon, Sep 17, 2012 at 7:57 AM, Cam Hutchison wrote:
> When awk runs, it reads its input until EOF. In your loop, the first run
> of awk is consuming all the input from stdin (cat input) and printing
> the first line. For the subsequent iterations through the loop, awk no
> longer has anything to
Morning Star writes:
>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
When awk runs, it reads its input until EOF. In your loop, the first run
of awk
On Sun, Sep 16, 2012 at 4:28 PM, Christofer C. Bell
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 po
On Sun, Sep 16, 2012 at 3:44 AM, Morning Star
wrote:
> 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
>
On Sun, Sep 16, 2012 at 3:53 PM, Teemu Likonen wrote:
> 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
>
thanks, Teemu. i already know that, but
On Sun, Sep 16, 2012 at 4:14 PM, emmanuel segura wrote:
> awk '/line/ {print; if(FNR % 3 == 0){exit}}' var
>
thanks, emmanuel. i already know that, but right now i need to understand
how passing for loop bash variables to awk works.
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.
On Sun, Sep 16, 2012 at 3:59 PM, Alex Hutton wrote:
> I would do :
> cat input | head -n3
>
thanks, alex. i already know that, but right now i need to understand
how passing for loop bash variables to awk works.
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject
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:
>
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 i
9 matches
Mail list logo