LoginSignup
59
43

More than 5 years have passed since last update.

【bash】行ごとに処理する

Last updated at Posted at 2015-02-04

自分用のメモ。
行ごとに処理する方法。while readとfor inの二通りの方法がある。

while read

while_read
cat out.dat | while read line
do
echo $line
done

for in

for_in
IFS=$'\n'
for line in `cat out.dat`
do
echo $line
done

IFSは環境変数で区切り文字が設定される。
区切り文字のデフォは改行、タブ、スペースなので、改行のみにしてている。

59
43
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
59
43