# 1行ずつ処理をする

# Bash

echo "$LINES" | while read LINE
do
    echo "XXX| $LINE"
done

# ダメな例1(1行にまとまってしまう)

echo $LINES | while read LINE
do
    echo "XXX| $LINE"
done

# ダメな例2(1単語ずつ読まれてしまう)

for LINE in $LINES
do
    echo "XXX| $LINE"
done

# ダメな例3(分割されない)

for LINE in "$LINES"
do
    echo "XXX| $LINE"
done

# Python

for line in lines.splitlines():
  print "XXX: %s" % line

# Ruby

lines.each_line {|line|
  puts "XXX| #{line}"
}

[ 📩 ご意見 ]