在KornShell中对字符串进行标记

时间:2011-09-30 10:17:18

标签: bash shell scripting ksh tokenize

我需要在KornShell(ksh)中用字符串标记。我有bash的以下脚本;但它似乎不适用于ksh。

脚本如下。请帮助为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

1 个答案:

答案 0 :(得分:2)

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