리눅스 wc

1 개요[ | ]

word count; wc
리눅스 wc
/usr/bin/wc
  • 행 수, 단어 수, 바이트 수 등을 세는 리눅스 명령어
  • 문자수, 가장 긴 행의 길이(바이트 수)도 표시 가능

2 실습 1: 기본형[ | ]

  • 기본형은 잘 안쓴다…
[root@localhost ~]# echo hello > 1.txt
[root@localhost ~]# echo hello world > 2.txt
[root@localhost ~]# wc 1.txt 2.txt
 1  1  6 1.txt
 1  2 12 2.txt
 2  3 18 total
→ 1.txt는 1행 1단어 6바이트[1]
→ 2.txt는 1행 2단어 12바이트

3 실습 2: 행수 세기 ★[ | ]

  • 아마도 가장 많이 사용하는 옵션일 것이다.
ifconfig 실행결과의 줄 수 세기
[root@localhost ~]# ifconfig | wc -l
18
/etc/services 파일의 줄 수 세기
[root@localhost ~]# cat /etc/services | wc -l
9249

4 실습 3: 가장 긴 행의 바이트수[ | ]

  • -L, --max-line-length
[root@localhost ~]# cat 3.txt
friend
of
mine
[root@localhost ~]# cat 3.txt | wc -L
6
→ 가장 긴 행은 friend 6자

5 같이 보기[ | ]

6 주석[ | ]

  1. hello는 5문자이지만 맨 뒤에 개행문자까지 포함됨

7 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}