News for hackers. Stuff that matters.
Re:Learn to use Awk with hundreds of examples by oblio on Wednesday October 25, 2017 @09:03AM (#15549705)
awk is my go-to tool for simple command line tokenizer. Hard to beat:

awk '{ print $1; }'

Other than that... not really. Maybe the advantage would be ubiquity, if you really, really want to avoid Perl.

Re:Learn to use Awk with hundreds of examples by cyborgx7 on Wednesday October 25, 2017 @09:22AM (#15549845)
>Hard to beat: awk '{ print $1; }'

How about: cut -f 1 -d ' '

You don't even need the -d flag if the you happen to be able to use the default delimiter, like in your example.

Re:Learn to use Awk with hundreds of examples by zb on Wednesday October 25, 2017 @09:36AM (#15549940)
I used to regularly do ad-hoc text processing, typically on a 24 hour log of GPS data (on an early-2000s-era computer). Surprisingly enough, awk is many times faster than cut for any data set big enough for you to notice time passing.
Re:Learn to use Awk with hundreds of examples by fnord123 on Wednesday October 25, 2017 @09:43AM (#15550000)
Awk delimits on whitespace by default. cut cannot do that afaict. So if you have something like this cut wont work:

    apples  1
    bananas 2
Re:Learn to use Awk with hundreds of examples by ninkendo on Wednesday October 25, 2017 @10:31AM (#15550412)
Exactly, which makes cut kinda shit for 99% of common "split-on-whitespace" tasks IMO.
Re:Learn to use Awk with hundreds of examples by dredmorbius on Wednesday October 25, 2017 @10:59AM (#15550653)
You can always use awk with IFS/OFS values to clean up the delimiters so you can pass the data off to cut ;-)
Re:Learn to use Awk with hundreds of examples by sbmassey on Wednesday October 25, 2017 @12:09PM (#15551341)
There's always plain old bash

while read a _; do echo $a; done