awk question

krad kraduk at gmail.com
Mon Oct 5 10:00:35 UTC 2015


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 at 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 at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "
> freebsd-questions-unsubscribe at freebsd.org"
>


More information about the freebsd-questions mailing list