命令简介wc命令用于统计文件中的行数、字数或字节数,然后在终端输出结果。我们可以使用wc命令来计算文件的字节数、字数或列数。语法格式wc[options][file]wc[OPTION][FILE]optiondescription-c#statisticsbytes-l#statisticslines-m#statisticscharacters-w#statisticswords-L#displaythelongestlineLength-help#Displayhelpinformation--version#显示版本信息应用实例查看一个文件的字节数、字数、行数[root@centos7~]#wctest.txt634140test.txt[root@centos7~]#wcmingongge.file000mingongge.file[root@centos7~]#wc-Ltest.txt29test.txt[root@centos7~]#wc-mtest.txt140test.txt[root@centos7~]#wc-ltest.txt6test.txt[root@centos7~]#wc-ctest.txt140test.txt统计所有文件行数和当前目录总行数[root@centos7~]#wc-l*48anaconda-ks.cfgwc:goinception:是目录0goinception45222goInception-linux-amd64-v1.2.3.tar.gzwc:httpd-2.4.46:是目录d6623.4dhttpd2.4.46.tar.gz0mingongge.filewc:testdir:是一个目录0testdir6test.txt81522totalwithcommandoutputtocount[root@centos7~]#ls-l|wc-l9[root@centos7~]#ls-ltotal21888-rw------。1rootroot1320Aug2010:39anaconda-ks.cfgdrwxr-xr-x3rootroot39Aug3003:48goinception-rw-r--r--1rootroot13034487Aug3003:42goInception-linux-amd64-v1.2.3.tar.gzdrwxr-sr-x11root404096Dec2422:35httpd-2.4.46-rw-r--r--1rootroot9363314Aug507:32httpd-2.4.46.tar.gz-rw-r--r--1rootroot0Jan208:43mingongge.filedrwxr-xr-x3rootroot210Jan1610:19testdir-rw-r--r--1rootroot140Jan1610:30test.txt
