Follow

I want to learn awk so I can do cool efficient text pipeliney things (like start printing on match, stop printing on another match, or run such and such command on a subset of the stream), but everytime I look at a tutorial for it, I think "these aren't practical" or "this makes no sense".

@zachdecook I have to look up how to use awk/sed pretty much every time I need them. I thought using a tee might work for you, so I searched using that as a key word as well. I probably don't understand your precise need, but this may be a starting point for you:
command | awk '{ if (/pattern/) { print > "match" } else { print > "nomatch" } }'
unix.stackexchange.com/questio
Didn't actually use tee and there is another version on that page.

Sign in to participate in the conversation
Librem Social

Librem Social is an opt-in public network. Messages are shared under Creative Commons BY-SA 4.0 license terms. Policy.

Stay safe. Please abide by our code of conduct.

(Source code)

image/svg+xml Librem Chat image/svg+xml