You are not logged in.
Pages: 1
I am looking for a way to cut a string by finding a space in a line of text
example
The cat sat on the mat
I want The?
in a string
tried looking at awk sed [ cut -f 1 works!] but need some way to store outpur of a command in a string ? eval ?
ok ok I have searched but I am not getting the right thing and you dudes know what you are talking about :-)
MrG
Mr Green
Offline
well, sticking with cut:
sto="$(echo "The cat sat on the mat" | cut -f1 -d" ")"
will store "The" in sto or you can go
phrase="The cat sat on the mat"
sto=${phrase%% *}
Offline
thanks man lol..... :-)
I assume eval is the way to get command output in a string .....?
will check out the link
Last edited by Mr Green (2008-07-13 09:48:24)
Mr Green
Offline
If you are getting into bash scripting, I highly recommend the Advanced Bash-Scripting Guide (http://tldp.org/LDP/abs/html/). It has taught me almost everything I know on the subject with supplements from google.
Offline
cool thanks a lot :-)
Mr Green
Offline
Pages: 1