Wc (Unix)

wc Befehl

wc (kurz für Englisch word count) ist ein durch POSIX und die Single UNIX Specification definierter Befehl auf der Kommandozeile, der in Unix- und unixoiden Systemen implementiert ist.

Das Programm liest die Standardeingabe oder eine Auflistung von Dateien und generiert daraus eine oder mehrere Statistiken: Anzahl Zeilen, Anzahl Wörter oder Anzahl an Zeichen. Bei der Angabe von einzelnen Dateien wird die Ausgabe für jede Datei und eine Zusammenfassung erzeugt.

Das Programm kann folgendermaßen aufgerufen werden:

 $ wc lorem.txt ipsum.log
      40     149     947 lorem.txt
    2294   16638   97724 ipsum.log
    2334   16787   98671 total

Die erste Spalte gibt dabei die Anzahl der Zeilen an. In dem Beispiel hat die Datei lorem.txt 40 Zeilen. Die Datei ipsum.log hingegen hat 2294 Zeilen. Insgesamt enthalten die Dateien also 2334 Zeilen. Die zweite Spalte gibt die Anzahl an Wörter in den Dateien an. Die letzte Spalte gibt die Anzahl an Zeichen in den Dateien an.

Neuere Versionen von wc können zwischen Bytes und Zeichen unterscheiden. Dieser Unterschied wird bei Unicode-Zeichen relevant, diese können mehrere Bytes pro Zeichen besitzen. Das Verhalten kann mit den -c oder -m Kommandozeilenschaltern gesteuert werden.

GNU wc war Teil des GNU textutils-Pakets, gehört aber inzwischen dem GNU-coreutils-Paket an.

Benutzung

  • wc -l <filename> Gibt die Anzahl Zeilen an (nur wenn von einem Zeilenumbruch gefolgt)
  • wc -c <filename> Gibt die Anzahl an Bytes an
  • wc -m <filename> Gibt die Anzahl an Zeichen an
  • wc -L <filename> Gibt die Länge der längsten Zeilen an (GNU Erweiterung)
  • wc -w <filename> Gibt die Anzahl der Wörter an

Siehe auch

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.