0
1

More than 5 years have passed since last update.

[短文メモ][備忘録][bash]半角スペースじゃなく改行区切りで for i in $(command) したい場合のforの代替

Last updated at Posted at 2016-12-20

ググっても、IFS変えて戻す、みたいなクソめんどくさい方法が出ることが多かったのだけど。 http://askubuntu.com/questions/344407/how-to-read-complete-line-in-for-loop-with-spaces に、なかなかいい方法があった。
どうせまた忘れて、ググる羽目になりそうだから書いとく。

スペース区切りのループと改行区切りのループ
# スペース区切り
for i in $(command) ; do command2 "$i" ; done

# 改行区切り
command | while read i ; do command2 "$i" ; done
0
1
0

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
0
1