LoginSignup
1
1

More than 5 years have passed since last update.

変数の値に改行コードが含まれているか調べる

Posted at

変数に格納されたテキストが複数行か、つまり改行コードを含んでいるか調べます。
Bash で動作を確認しました。

var="line1
line2
line3"
[[ ${var/$'\n'} == $var ]] || echo 'newline(s) in $var'
1
1
5

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