Bash IFS没有正确拆分字符串

时间:2017-09-14 02:15:26

标签: bash ifs

我无法让IFS根据冒号分隔符正确拆分字符串。似乎字符串中的-e被视为一个选项,而不是被视为文字字符串。

#!/bin/bash
string_val="-e:SQA"

IFS=: read -a items <<< "$string_val"

echo "${items[0]}" # Prints empty value
echo "${items[1]}" # Prints SQA

如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

正确拆分字符串; var thetext=''; .getText('//span[@class="price"]' ,fucntion(result){ thetext=result.value(); }) 中的-e被视为${items[0]}的选项。

echo