0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

LINUX コマンド【wc 編】使用例

Posted at

wc コマンド

ーファイルの「行数」「単語数」「バイト数」を表示してくれる

$wc
$ $wc /etc/passwd
実行結果
[hkoen@localhost ~]$ wc /etc/passwd
  44  101 2433 /etc/passwd

44:行数
101:単語数
2433:バイト数

オプションコマンド

・-l:行数のみ
・-w:単語数のみ
・-c:バイト数のみ

実行結果(-l)
[hkoen@localhost ~]$ wc -l /etc/passwd
 44 /etc/passwd

実際にどう使うの?!

wc -lで行数をカウントする手順は、
内容のわからないファイルに対してcatやgrepを行う前によく使われます。
知らないファイルをいきなりcatやgrepをしてしまうと、
端末上に膨大な行の結果が出力されてしまう恐れがあるからです。

また、特定の文言を指定したgrepと組み合わせたログ解析の目的でも使われます。
WEBサーバ上の特定のアプリケーションに対するアクセス件数を調査したり、バッチ処理の結果を調査する際にも有用です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?