【问题标题】:Tokenize a string in KornShell在 KornShell 中标记字符串
【发布时间】:2011-11-28 08:49:00
【问题描述】:

我需要在 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

【问题讨论】:

  • read -a&lt;&lt;&lt; 是 bash 功能,而不是 ksh。

标签: bash shell scripting ksh tokenize


【解决方案1】:
# s=a,b,c
# IFS=,
# set -A arr $s
# for e in "${arr[@]}"; do print -- "$e"; done
a
b
c

【讨论】:

  • 嗨 Dimitre,非常感谢,我能够使用提供的脚本对字符串进行标记,再次感谢
猜你喜欢
  • 2010-12-16
  • 2010-09-20
  • 2014-07-26
  • 2011-05-31
  • 1970-01-01
  • 1970-01-01
  • 2013-11-07
相关资源
最近更新 更多