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.
awk '{ print $1; }'
Other than that... not really. Maybe the advantage would be ubiquity, if you really, really want to avoid Perl.
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.
apples 1
bananas 2while read a _; do echo $a; done