bug-gawk
[Top][All Lists]
Advanced

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

Re: Is it bug ? as it's so confusing


From: david kerns
Subject: Re: Is it bug ? as it's so confusing
Date: Sat, 1 May 2021 06:32:10 -0700

I usually use multiple patterns to set/clear a flag then use the flag to do
the action:
echo -e 'a\nb\nc\nend\ne\nf\ng\n' |awk 'NR==1{on=1}/end/{on=0}on==1{print
$0}'
(move the print to change inclusiveness of the "delimiters")

On Sat, May 1, 2021 at 6:22 AM Budi <budikusasi@gmail.com> wrote:

> How to have awk to get range or boundary of the beginning to a pattern
> tried 1 fails as
>
> $ echo -e 'a\nb\nc\nend\ne\nf\ng\n' |awk '1,/end/ {print $0}'
> a
> b
> c
> end
> e
> f
> g
> this for all as pattern works
>
> $ echo -e 'a\nb\nc\nend\ne\nf\ng\n' |awk '/b/,/end/ {print $0}'
> b
> c
> end
> but back to question how to get range or boundary of the beginning to a
> pattern?
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]