Snehan Solomon
Snehan Solomon

Reputation: 432

Tokenize a string in KornShell

I need to tokenize in string in KornShell (ksh). I have got the following script for bash; but it does not seem to work in ksh.

The script is below. Please help in making work for ksh.

OLDIFS=$IFS
IFS=","
read -a array <<< "$(printf "%s" "$APPLICATION_NAMES")"
IFS=$OLDIFS
for i in "${array[@]}"
do
   :
   # do whatever on $i
   echo "Checking status of $i"
done

Upvotes: 1

Views: 1498

Answers (1)

Dimitre Radoulov
Dimitre Radoulov

Reputation: 28000

# s=a,b,c
# IFS=,
# set -A arr $s
# for e in "${arr[@]}"; do print -- "$e"; done
a
b
c

Upvotes: 2

Related Questions