English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux wc Befehl

Linux Command大全

Der Linux wc-Befehl wird verwendet, um die Anzahl der Wörter zu berechnen.

Mit dem wc-Befehl können wir die Byte-Größe, die Wortanzahl oder die Spaltenanzahl einer Datei berechnen. Wenn keine Dateiname angegeben ist oder der angegebene Dateiname "-" dann liest das wc-Befehl Daten vom Standard-Eingabegerät.

Syntax

wc [-clw][--help][--version][Datei...]

Parameter:

  • -c oder--bytes oder--chars Zeige nur die Bytes.

  • -l oder--lines Zeige die Anzahl der Zeilen.

  • -w oder--words Zeige nur die Anzahl der Wörter.

  • --help Online-Hilfe.

  • --version Anzeigen Sie Versionsinformationen.

Online-Beispiel

Standardmäßig berechnet wc die Anzahl der Zeilen, Wörter und Bytes der angegebenen Datei. Der verwendete Befehl ist:

wc testfile

Zunächst überprüfen Sie den Inhalt der Datei testfile, und Sie können sehen:

$ cat testfile  
Linux-Netzwerke werden immer häufiger, aber die Sicherheit wird oft übersehen  
Problem. Leider sind alle Netzwerke in heutiger Zeit potenzielle Zielscheine für Hacker,  
fro0m tp-geheimen militärischen Forschungsnetzwerken bis hin zu kleinen Heimbüronetzwerken.  
Linux Network Security konzentriert sich darauf, Linux in einem vernetzten Umfeld zu sichern, wo die  
Die Sicherheit des gesamten Netzwerks muss berücksichtigt werden, anstatt nur isolierte Maschinen zu betrachten.  
It uses a mix of theoretical and practical techniques to teach administrators how to install and  
use security applications, as well as how the applications work and why they are necessary.

Using wc to count, the result is as follows:

$ wc testfile           #Statistics information of testfile file  
3 92 598 testfile     #Lines of testfile file3、Word Count92、Byte Count598

Among them,3 The numbers represent the line count, word count, and byte count of the testfile.

If you want to count the information of multiple files at the same time, for example, count the information of testfile and testfile_1、testfile_2,You can use the following command:

wc testfile testfile_1 testfile_2   #Statistics of three files

Output results as follows:

$ wc testfile testfile_1 testfile_2  #Statistics of three files  
3 92 598 testfile                    #Lines of the first file3、Word Count92、Byte Count598  
9 18 78 testfile_1                   #Lines of the second file9、Word Count18、Byte Count78  
3 6 32 testfile_2                    #Lines of the third file3、Word Count6、Byte Count32  
15 116 708 Total Usage                    #Total lines of three files15、Word Count116、Byte Count708

Linux Command大全