LoginSignup
3
2

More than 1 year has passed since last update.

シェル | for 文を文字列で回す時はクォートしない

Last updated at Posted at 2017-10-05

クォートした場合

文字列全体が1要素として扱われてしまう。

for text in 'a b c'; do
  echo $text
done
a b c

クォートしない場合

スペース区切りで各要素が扱われる。

for text in a b c; do
  echo $text
done
a
b
c

クォートで分割する場合

for text in 'a b' 'c'; do
  echo $text
done
a b
c

環境

  • GNU bash, version 4.4.0(1)-release (x86_64-apple-darwin15.6.0)

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

3
2
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
3
2