wc 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-wc
핵심 정리
- 파일의 줄 수, 단어 수, 바이트 수를 셉니다. 파일이 여럿이면 합계도 보여 줍니다.
- 파일을 지정하지 않으면 표준 입력을 셉니다.
-l(줄),-w(단어),-c(바이트),-m(문자).-c와-m은 함께 쓸 수 없습니다.- 단어는 빈칸, 탭, 줄바꿈으로 나뉜 길이가 0이 아닌 문자열입니다.
-k(문자 수)는 앞으로 없어질 플래그라-m을 씁니다.- AIX 5.3과 6.1 문서의 내용이 같습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (두 버전 내용 같음) |
| 원문 | IBM Commands Reference — 5.3 Volume 6, 6.1 Volume 6 |
| 파일 | /usr/bin/wc, /bin/wc, /usr/ucb/wc(링크) |
| 관련 명령어 | cat, grep -c |
목적
파일의 줄, 단어, 바이트, 문자 수를 셉니다.
영어 원문
Counts the number of lines, words, bytes, or characters in a file.
구문
wc [ -c | -m ] [ -l ] [ -w ] [ File ... ]
원문 구문에는 없지만 플래그 표에는 -k도 있습니다.
설명
wc 명령은 기본으로 File 매개변수로 지정한 파일의 줄 수, 단어 수, 바이트 수를 셉니다. 줄바꿈 문자 수, 단어 수, 바이트 수를 표준 출력에 쓰고, 지정한 모든 파일의 합계를 냅니다.
File 매개변수를 쓰면 요청한 수와 함께 파일 이름도 표시합니다. File 매개변수에 파일 이름을 지정하지 않으면 표준 입력을 씁니다.
wc 명령은 LANG, LC_ALL, LC_CTYPE, LC_MESSAGES 환경 변수의 영향을 받습니다.
wc는 공백(예: 빈칸, 탭)으로 나뉜, 길이가 0이 아닌 문자열을 단어로 봅니다.
영어 원문
By default, the wc command counts the number of lines, words, and bytes in the files specified by the File parameter. The command writes the number of newline characters, words, and bytes to the standard output and keeps a total count for all named files.
When you use the File parameter, the wc command displays the file names as well as the requested counts. If you do not specify a file name for the File parameter, the wc command uses standard input.
The wc command is affected by the LANG, LC_ALL, LC_CTYPE, and LC_MESSAGES environment variables.
The wc command considers a word to be a string of characters of non-zero length which are delimited by a white space (for example SPACE , TAB).
플래그
| 플래그 | 설명 |
|---|---|
-c |
바이트 수를 셉니다. -k를 함께 지정하면 문자 수를 셉니다. |
-k |
문자 수를 셉니다. -k만 지정하면 -klwc를 지정한 것과 같습니다. 다른 플래그와 함께 쓸 때는 -c도 넣어야 하며, 아니면 -k를 무시합니다(예제 4·5 참고). 참고: 이 플래그는 앞으로 없어질 예정입니다. |
-l |
줄 수를 셉니다. |
-m |
문자 수를 셉니다. -c와 함께 쓸 수 없습니다. |
-w |
단어 수를 셉니다. 단어는 빈칸, 탭, 줄바꿈으로 나뉜 문자열입니다. |
참고: 플래그를 지정하지 않으면 파일이나 표준 입력의 줄 수, 단어 수, 바이트 수를 셉니다.
영어 원문
-c— Counts bytes unless the-kflag is specified. If the-kflag is specified, the wc command counts characters.-k— Counts characters. Specifying the-kflag is equivalent to specifying the-klwcflag. If you use the-kflag with other flags, then you must include the-cflag. Otherwise, the-kflag is ignored. For more information, see examples 4 and 5. Note: This flag is to be withdrawn in a future release.-l— Counts lines.-m— Counts characters. This flag cannot be used with the-cflag.-w— Counts words. A word is defined as a string of characters delimited by spaces, tabs, or newline characters.- Note: If no flag is specified, wc by default counts the lines, words, bytes in a file or from standard
input.
종료 상태
| 값 | 뜻 |
|---|---|
| 0 | 잘 끝났습니다. |
| 0보다 큼 | 오류가 났습니다. |
영어 원문
This command returns the following exit values:
- 0 — The command ran successfully.
>0— An error occurred.
예제
- 파일의 줄, 단어, 바이트 수를 표시합니다.
chap1파일의 줄 수, 단어 수, 바이트 수가 나옵니다.
wc chap1
- 바이트 수와 단어 수만 표시합니다.
chap로 시작하는 파일마다 바이트 수와 단어 수를 보여 주고, 그 파일들의 합계도 보여 줍니다.
wc -cw chap*
- 파일의 줄, 단어, 문자 수를 표시합니다.
wc -k chap1
- 파일의 단어 수와 문자 수를 표시합니다.
wc -kcw chap1
- 표준 입력에 대해 씁니다. 표준 입력의 줄 수와 단어 수를 보여 주며,
-c가 없으므로-k는 무시합니다.
wc -klw
- 파일의 문자 수를 표시합니다.
wc -m chap1
- 표준 입력의 줄, 단어, 문자 수를 표시합니다.
wc -mlw
영어 원문
- To display the line, word, and byte counts of a file, enter:
wc chap1
The wc command displays the number of lines, words, and bytes in the chap1 file.
- To display only byte and word counts, enter:
wc -cw chap*
The wc command displays the number of bytes and words in each file that begins with chap. The command also displays the total number of bytes and words in these files.
- To display the line, word, and character counts of a file, enter:
wc -k chap1
The wc command displays the number of lines, words, and characters in the chap1 file.
- To display the word and character counts of a file, enter:
wc -kcw chap1
The wc command displays the number of characters and words in the chap1 file.
- To use the wc command on standard input, enter:
wc -klw
The wc command displays the number of lines and words in standard input. The -k flag is ignored.
- To display the character counts of a file, enter:
wc -m chap1
The wc command displays the number of characters in the chap1 file.
- To use the wc command on standard input, enter:
wc -mlw
The wc command displays the number of lines, words, and characters in standard input.
파일
| 파일 | 설명 |
|---|---|
/usr/bin/wc, /bin/wc |
wc 명령이 들어 있습니다. |
/usr/ucb/wc |
wc 명령에 대한 심볼릭 링크입니다. |
영어 원문
- /usr/bin/wc, /bin/wc — Contains the wc command.
- /usr/ucb/wc — Contains the symbolic link to the wc command.
Related information:
- Files
- Input and output redirection
리눅스(GNU)와 다른 점
| 항목 | AIX 5.3·6.1 | GNU wc |
|---|---|---|
-k |
문자 수(없어질 예정) | 없음 |
-c와 -m |
함께 쓸 수 없음 | 함께 쓸 수 있음 |
AIX 5.3·6.1 문서에는 -L(가장 긴 줄의 길이), --files0-from 같은 GNU 플래그가 없습니다.