Tech Journal Back to Tech Journal

What's the shortest way to isolate a word in a line in a shell script?

Pipe it through gawk '{print $1}' to print out the first space-seperated token. If the tokens are seperatred by colons (:), then use gawk -F: '{print $1}'.

Last updated on 2006-08-02 14:00:00 -0700, by Shalom Craimer

Back to Tech Journal