60
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

60
42
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
60
42

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?