ホームページ  >  記事  >  運用・保守  >  Linuxのwcコマンドの使い方

Linuxのwcコマンドの使い方

WBOY
WBOY転載
2023-05-17 12:31:061941ブラウズ

Linux の wc コマンドは単語数をカウントするために使用されます。

wc コマンドを使用すると、ファイルのバイト数、ワード数、または列数を計算できます。ファイル名が指定されていない場合、またはファイル名が "-" として指定されている場合、wc コマンドは標準入力デバイスからファイルを読み取ります データを読み取ります。

構文:

wc

パラメータ:

-c または --bytes または --chars バイト数のみ表示されています。

-l または --lines は行数を表示します。

-w または --words は単語数のみを表示します。

--ヘルプ オンライン ヘルプ。

--version バージョン情報を表示します。

例:

デフォルトでは、wc は指定されたファイルの行数、ワード数、およびバイト数を計算します。使用するコマンドは次のとおりです。

wc

まず、テストファイル ファイルの内容を確認します。次のことがわかります。

$ cat testfile  
Linux networks are becoming more and more common, but scurity is often an overlooked  
issue. Unfortunately, in today’s environment all networks are potential hacker targets,  
fro0m tp-secret military research networks to small home LANs.  
Linux Network Securty focuses on securing Linux in a networked environment, where the  
security of the entire network needs to be considered rather than just isolated machines.  
It uses a mix of theory and practicl techniques to teach administrators how to install and  
use security applications, as well as how the applcations work and why they are necesary.

Use wc統計を使用すると、結果は次のようになります。

$ wc testfile           # testfile文件的统计信息  
3 92 598

Among 3 つの数字はそれぞれ、testfile ファイルの行数、ワード数、バイト数を示します。

testfile、testfile_1、testfile_2 など、複数のファイルの情報を同時にカウントしたい場合は、次のコマンドを使用できます。

wc

出力結果は次のとおりです:

$ wc testfile testfile_1 testfile_2  #统计三个文件的信息  
3 92 598 testfile                    #第一个文件行数为3、单词数92、字节数598  
9 18 78 testfile_1                   #第二个文件的行数为9、单词数18、字节数78  
3 6 32 testfile_2                    #第三个文件的行数为3、单词数6、字节数32  
15 116 708

以上がLinuxのwcコマンドの使い方の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はyisu.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。