Wc (Unix)

wc (od ang. word count) – uniksowe narzędzie do liczenia linii, słów, bajtów (lub znaków) w pliku lub potoku. W GNU/Linuksie jest częścią pakietu GNU Coreutils.
Przykłady wykorzystywania
W przykładach wykorzystano plik o nazwie plik.txt, który zawiera tekst Zażółć gęślą jaźń. zapisany w kodowaniu UTF-8. Plik jest zakończony uniksowym znakiem końca linii (LF, "\n", 0x0A).
| Lp. (znak) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Znak | Z
|
a
|
ż
|
ó
|
ł
|
ć
|
|
g
|
ę
|
ś
|
l
|
ą
|
|
j
|
a
|
ź
|
ń
|
.
|
\n
| |||||||||
| Unikod | U+005A | U+0061 | U+017C | U+00F3 | U+0142 | U+0107 | U+0020 | U+0067 | U+0119 | U+015B | U+006C | U+0105 | U+0020 | U+006A | U+0061 | U+017A | U+0144 | U+002E | U+000A | |||||||||
| Lp. (bajt) | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| Bajt (szesnastkowo) | 5A | 61 | C5 | BC | C3 | B3 | C5 | 82 | C4 | 87 | 20 | 67 | C4 | 99 | C5 | 9B | 6C | C4 | 85 | 20 | 6A | 61 | C5 | BA | C5 | 84 | 2E | 0A |
- Wyświetlenie zawartości pliku na ekranie za pomocą programu
cat.$ cat plik.txt Zażółć gęślą jaźń.
- Uruchomienie programu
wcbez opcji wypisuje liczbę linii, słów i bajtów.$ wc plik.txt 1 3 28 plik.txt
- Uruchomienie programu
wcz opcją-lwypisuje liczbę linii.$ wc -l plik.txt 1 plik.txt
- Uruchomienie programu
wcz opcją-wwypisuje liczbę słów.$ wc -w plik.txt 3 plik.txt
- Uruchomienie programu
wcz opcją-cwypisuje liczbę bajtów.$ wc -c plik.txt 28 plik.txt
- Uruchomienie programu
wcz opcją-mwypisuje liczbę znaków.$ wc -m plik.txt 19 plik.txt
Linki zewnętrzne
- GNU Coreutils
- (ang.) man wc
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.
- 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:
- 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.
- 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.
- 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.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.