StackOverflow 文件 Bash 教程 逐行(和/或逐欄位)讀取檔案(資料流,變數) 逐行迴圈一個字串 逐行迴圈一個字串 Created: November-22, 2018 var='line 1 line 2 line3' while IFS= read -r line; do echo "-$line-" done <<< "$var" 要麼 readarray -t arr <<< "$var" for i in "${arr[@]}";do echo "-$i-" done 通過命令列逐行迴圈將字串的行讀入陣列