Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I split a word into characters shell script

Status
Not open for further replies.

Tison

Programmer
May 12, 1999
216
CH
I have a text string (eg dummy) which I need to split into "d u m m y"
Logic flow;
TXT=dummy
for each CHAR in $TXT
do
RESULT=$RESULT" "$CHAR
done
echo $RESULT
 
#!/usr/bin/ksh
TXT=dummy
LNTH=`echo $TXT | wc -c`
x=0
RESULT=""
while [ $x -ne $LNTH ]
do
let x=$x+1
RESULT="$RESULT`echo $TXT | cut -c $x` "
done
echo $RESULT


crowe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top