2
我想兩個包含字符串空間轉換到一個數組中的殼,就像這樣:如何將包含空格的字符串轉換爲shell中的數組?
param_values=$(parse_json_with_keys) # then, param_values: "select * from t" "terry"
當我將它們轉換爲數組:
param_values=(${param_values})
echo ${param_values[0]} # output: "select
echo ${param_values[1]} # output: *
但我希望輸出:
echo ${param_values[0]} # output: select * from t
echo ${param_values[1]} # output: terry
這讓我很困惑。有人能幫助我嗎?非常感謝!
這意味着,它在限定空白空間,並將其分配給變量。 – LethalProgrammer
parse_json_with_keys的輸出是什麼?來自parse_json_with_keys的字符串是否由「\ n」分隔? – Abis
@Abis parse_json_with_keys將輸出:「select * from t」「terry」 – ouyangyewei