LoginSignup
0
0

More than 3 years have passed since last update.

ShellScript 変数 に 格納 されている 文字数 を出力する

Posted at

目的

  • ShellScriptで変数の中に格納された文字列の文字数を表示する方法を知る。

書き方の例

  • 変数には任意の文字列が格納されているものとする。
  • ターミナルに変数の文字を出力したいのでechoコマンドの後に紹介する処理を記載する。
  • 下記にShellScriptの処理を記載する。
echo ${#変数名}

具体的な例

  • 変数stringに文字列Hellowを格納する。
  • 下記にShellScriptの処理を記載する。 ※>はターミナルの出力を表す。
string="Hellow Japan"
echo ${#string}
>12
0
0
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
0