LoginSignup
6
2

More than 3 years have passed since last update.

コンソールで文字数をカウントする

Posted at

コンソールで文字数をカウントする方法。

一行の場合

$ echo -n '文字列' | wc -m
  • echo -n: -n オプションで出力文字の最後を改行させない。
  • wc -m: -m オプションで文字数を表示。(マルチバイト文字対応)

複数行の場合

$ echo -n '文字列' | tr -d '\n' | wc -m
  • tr -d '\n': -d オプションで改行コードを削除。
6
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
6
2