我的腳本:爲什麼讀命令讀取所有字爲頭名
#!/bin/bash
IFS=','
read a b c d e f g <<< $(echo "1,2,3,4,5,6,7") # <- this could be any other commands, I am just making up a dummy command call
echo $a
echo $b
echo $c
我,它預計到輸出
1
2
3
而是將其輸出:
1 2 3 4 5 6 7
blank line
blank line
我做了什麼錯誤?
https://www.gnu.org/軟件/ bash/manual/bash.html#Word-Splitting – 4ae1e1
[Linux bash:多變量賦值]的可能重複(http://stackoverflow.com/questions/1952404/linux-bash-multiple-variable-assignment) – itwasntme
你只需要引用子命令「$()」'並且它會按照你的預期工作,否則'''會過早地被擴展。 – 123