while read の使い方
while read line; do echo $line done < <( printf "hello\nworld\nbye\n" )
参考:
シェルスクリプトでよく使われる while read line 4パターン | eTuts+ Server Tutorial
Bash で for よりも while read を使い、効率的にファイルと文字列を扱う | grep Tips
while 文の使用方法 | UNIX & Linux コマンド・シェルスクリプト リファレンス (SUNONE)
ファイルの中身を一行ずつ読み込む方法 | server-memo.net
bash でファイルの内容を読み込む | とある技術者の外部記憶媒体
bash の while ループ内の変数をループ外で使う | bit
bash populate an array in loop – Stack Overflow
Why is the array empty after the while loop? – Unix & Linux Stack Exchange
bash trouble assigning to an array index in a loop – Stack Overflow
ファイルの最終行に改行がない場合の処理
参考:
BASH の while read で最終行が処理されない問題の解決方法 – Qiita
IFS
参考:
read するときは IFS= を付けておくと strict な感じで気持ちが良い – Qiita
ループの出力をソートする
参考:
How to process a while-do loop and sort the iterated output – Unix & Linux Stack Exchange