Rishi Pahuja
Answered On : Jun 6th, 2005
echo $string | cut -d" " -f1
echo $string | cut -d" " -f2
echo $string | cut -d" " -f3
Login to rate this answer.
abhay
Answered On : Jul 5th, 2005
echo "one two three" | cut -d" " -f 1,2,3
or
echo "one two three" | awk '{print $1 $2 $3}'

3 Users have rated as useful.
Login to rate this answer.
akebono
Answered On : Jul 27th, 2005
sed and awk
Login to rate this answer.
rno
Answered On : Oct 5th, 2006
cut , awk, sed and others are not "SHELL" commands. One way could be with bash: string="one two three"tab=($string)$ echo ${tab[0]}one$ echo ${tab[1]}two$ echo ${tab[2]}threehttp://www.big-up.org
Login to rate this answer.
atrain
Answered On : Mar 20th, 2007
echo "one two three" | while read ONE TWO THREE
print $ONE
one
print $TWO
two
print $THREE
three
Login to rate this answer.
pranab kumar ghosh
Answered On : Apr 4th, 2007
set -- one two three
echo $1
echo $2
echo $3
Login to rate this answer.
Jitu
Answered On : Apr 13th, 2007
Hi all,
Can we use like this..
echo $string | tr " " "n"
Here the output will be something like this
One
Two
Three
if the value of string="One Two Three"
Please make me clear if i am wrong..i am a new baby to shell scripting. :-)
Thanks,
Jitu
Login to rate this answer.
Vishwajeet
Answered On : Jun 27th, 2007
Hi The answer is excellent but I like to modify it a little, only the command
string="one two three"tab=($string)$ echo ${tab[0]}one ${tab[1]}two ${tab[2]}three it self is enough to ptint "one two three", no more echos' are required.
Login to rate this answer.
input="one two three"
echo $input | tr " " "n"
output would be like :
one
two
three
one of my friend gave this answer but in place of "n" he gave "n" only which will gave
output like :
onentwonthree
thanks
Login to rate this answer.
Sorry typo error... in place on n we have to give "n"
Login to rate this answer.
echo "one two three" | awk '{print $0 }'
$0willreturn the entire string as it'swithin quotes and will treat as one.
Login to rate this answer.
Try this:
echo "one two three" | xargs
the output is: one two three
Login to rate this answer.
Login to rate this answer.