Juan Diego Tascón writes:

> I have always wondered if there is a way to do awk '{ print $1}' using
> only builtin bash functions when you only have a one line string

str="one two five"

# remove all from the first blank on, but will not work with
# other whitespace
echo ${str%% *}

or

# set $1, $2, $3, ... to words of $str
set $str
echo $1

or

# create array holding one word per element
strarr=( $str )
echo $strarr  (or echo ${strarr[0]})

        Wonko

Reply via email to