Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2015 11:00:33 +0100
From:      krad <kraduk@gmail.com>
To:        Quartz <quartz@sneakertech.com>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: awk question
Message-ID:  <CALfReyefjMTrUW1YhPZC3n2QwPMOVZJxS8oMtgU_jo9sG%2BqgaQ@mail.gmail.com>
In-Reply-To: <56124479.9020505@sneakertech.com>
References:  <5611C922.4050007@hiwaay.net> <20151005042129.1f153ec6.freebsd@edvax.de> <5611F776.9090701@hiwaay.net> <56124479.9020505@sneakertech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Just to add to the pile, if you want to pull a section out of a file you
can do something along the lines of this.

# for p in {a..z}; do echo $p; done | awk '/^k/,/^t/ {print $0}'
k
l
m
n
o
p
q
r
s
t


On 5 October 2015 at 10:35, Quartz <quartz@sneakertech.com> wrote:

> Funny you mention grep, I had a similar conversation on the NetBSD list
>> last week & everyone there suggested using awk alone to 'grep' out the
>> lines I wanted.
>>
>
> Awk, sed, and various other utilities all have basic regex line matching,
> so if you're already calling them for some other feature then piping the
> output through grep first is kinda silly and inefficient. It's sorta like
> doing $(cat foo.txt | grep 'bar') instead of just $(grep 'bar' foo.txt). I
> suggested it mainly because it's easy to understand conceptually and
> because awk's syntax has something of a steep learning curve.
>
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALfReyefjMTrUW1YhPZC3n2QwPMOVZJxS8oMtgU_jo9sG%2BqgaQ>