linux的wc打印換行符,字和字節計數

wc打印換行符,字和字節計數,而且支持多個文件打印,命令格式:bash


wc [OPTION]... [FILE]...ide

spa

wc [OPTION]... --files0-from=F日誌


經常使用方式:ci

  1. 查看 error.log 日誌總行數input

    wc -l error.log
  2. 查看 error.log 日誌總字節數it

    wc -c error.log
  3. 查看 log 目錄下 error.* 類的文件行數io

    wc -l log/error.*



參數列表:class


-c, --bytestest

   說明:打印文件的字節總數


-m, --chars

   說明:打印文件的字符總數


-l, --lines

   說明:打印文件的總行數


--files0-from=F    read input from the files specified by
                           NUL-terminated names in file F;
                           If F is - then read names from standard input

  說明:打印批量指定一些文件,字節,行數,字符數等信息。

           當F爲文件名時會讀取指定的文件名(所讀取的文件內容應該是因此指定的文件名列表,而且每一個文件名結尾追加 ^@ 特殊符號,注意:這個符號並不是^與@而是按 Ctrl+V而後再輸入10而且再按其它鍵便可看到類型 ^@ 藍色的符號)。如:

文件 test.wc 內容:

sh.log^@test.sh^@

命令:

wc --files0-from=test.wc

結果:

[root@localhost ~]# wc --files0-from=test.txt
  460275  1332379 40275303 sh.log
       9       25      338 test.sh
wc: 
: No such file or directory
  460284  1332404 40275641 total

           當F爲 - 則表示接收標準輸入讀取,通常使用 | 管道輸入到wc,如:

find . -name '*.log' -print0 |wc --files0-from=-

還能夠使用命令相看相關說明:

info wc


-L, --max-line-length

  說明:打印文件中長度最長行的行數


-w, --words

   說明:打印文件中的單詞個數


--help

   說明:顯示幫助信息


--version

   說明:打印當前命令版本信息

相關文章
相關標籤/搜索