>  기사  >  운영 및 유지보수  >  Linux wc 명령을 사용하는 방법

Linux wc 명령을 사용하는 방법

WBOY
WBOY앞으로
2023-05-17 12:31:061945검색

Linux wc 명령은 단어 수를 계산하는 데 사용됩니다.

wc 명령을 사용하면 파일의 바이트, 단어 또는 열 수를 계산할 수 있습니다. 파일 이름이 지정되지 않거나 파일 이름이 "-"로 지정되면 wc 명령은 파일에서 데이터를 읽습니다. 표준 입력 장치.

구문: ​​

wc

매개변수:

-c 또는 --bytes 또는 --chars는 바이트 수만 표시합니다.

-l 또는 --lines는 줄 수를 표시합니다.

-w 또는 --words는 단어 수만 표시합니다.

--온라인 도움말을 참조하세요.

--version은 버전 정보를 표시합니다.

예:

기본적으로 wc는 지정된 파일의 줄 수, 단어 수, 바이트 수를 계산합니다. 사용된 명령은 다음과 같습니다.

wc

먼저 testfile 파일의 내용을 확인합니다.

$ cat testfile  
Linux networks are becoming more and more common, but scurity is often an overlooked  
issue. Unfortunately, in today’s environment all networks are potential hacker targets,  
fro0m tp-secret military research networks to small home LANs.  
Linux Network Securty focuses on securing Linux in a networked environment, where the  
security of the entire network needs to be considered rather than just isolated machines.  
It uses a mix of theory and practicl techniques to teach administrators how to install and  
use security applications, as well as how the applcations work and why they are necesary.

wc 통계를 사용하면 결과는 다음과 같습니다.

$ wc testfile           # testfile文件的统计信息  
3 92 598

그중 세 숫자는 줄 수를 나타냅니다. 단어 수 및 테스트 파일 파일 수입니다.

testfile, testfile_1, testfile_2 등 여러 파일의 정보를 동시에 계산하려면 다음 명령을 사용하면 됩니다.

wc

출력 결과는 다음과 같습니다.

$ wc testfile testfile_1 testfile_2  #统计三个文件的信息  
3 92 598 testfile                    #第一个文件行数为3、单词数92、字节数598  
9 18 78 testfile_1                   #第二个文件的行数为9、单词数18、字节数78  
3 6 32 testfile_2                    #第三个文件的行数为3、单词数6、字节数32  
15 116 708

위 내용은 Linux wc 명령을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제