Monday 15 April 2013

How can I split a string in KSH bash script? -



How can I split a string in KSH bash script? -

here's a link

i referred not able understand, how can split: testing123 testing , 123

temp=${str%%:*} #only if there colon in between in case there isn't.

if there space b/w them have gotten work.

update: want split letters , digits.

character count 5, testi, , number 4.

so if testi123.

i want var1 = testi, var2 = 123

var1=$(echo $stp | cutting '[a-z]' -f1) var2=$(echo $stp | cutting '[0-9]' -f1)

even didnt work, cut: [a-z]: no such file or directory cut: [0-9]: no such file or directory

any help appreciated.

the reply next questions is: echo "testi1234" |awk 'begin{fieldwidths="5 4"}{print $1 rs $2}'

now need store $1 , $2 in different variable , should go. if else has improve reply please comment, open learning new concepts.

ksh

No comments:

Post a Comment