2.3.16、wc:统计文本

关注公众号 “融码一生”,领取全套 PDF / 电子书

  • wc 命令:对文本进行统计,包括单词个数、行数、字节数
    • wc [选项] [文件名]
      • 选项:
        • -c:统计字节数
        • -w:统计单词数
        • -l:统计行数
[test1@VM-4-13-centos ~]$ wc -l <test.sh
:<<!
5
!

1、常用命令

(1)统计文件中的单词数

  • 英文文件(统计 word 数)
    • wc -w file_name
  • 中文文件(统计字符数;统计时换行符也会被统计进去)
    • wc -m file_name

(2)统计文件行数

  • wc -l file_name

2、参数解析

Usage: wc [OPTION]... [FILE]...
  or:  wc [OPTION]... --files0-from=F
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified.  A word is a non-zero-length sequence of
characters delimited by white space.

With no FILE, or when FILE is -, read standard input.

The options below may be used to select which counts are printed, always in
the following order: newline, word, character, byte, maximum line length.
  -c, --bytes            print the byte counts
  -m, --chars            print the character counts
  -l, --lines            print the newline counts
      --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
  -L, --max-line-length  print the maximum display width
  -w, --words            print the word counts
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Full documentation at: <https://www.gnu.org/software/coreutils/wc>
or available locally via: info '(coreutils) wc invocation'

关注公众号 “融码一生”,领取全套 PDF / 电子书

相关推荐

  1. 2.3.16、wc统计文本

    2024-04-03 09:22:01       12 阅读
  2. 【Linux】统计文件数量:ls -l | grep ^- | wc -l

    2024-04-03 09:22:01       29 阅读
  3. wc文件统计功能 && xargs && network 静态IP

    2024-04-03 09:22:01       12 阅读
  4. leetcode 2316.统计无向图中无法互相到达点对数

    2024-04-03 09:22:01       8 阅读
  5. 统计单词数量(文件)(*)

    2024-04-03 09:22:01       11 阅读
  6. linux统计文件数量命令

    2024-04-03 09:22:01       41 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-03 09:22:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-03 09:22:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-03 09:22:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-03 09:22:01       18 阅读

热门阅读

  1. 【蓝桥杯每日一题】4.2 全球变暖

    2024-04-03 09:22:01       12 阅读
  2. postcss安装和使用

    2024-04-03 09:22:01       14 阅读
  3. FastAPI+React全栈开发20 使用useEffect与api通信

    2024-04-03 09:22:01       17 阅读
  4. 负载均衡:实现高效稳定的网络服务

    2024-04-03 09:22:01       14 阅读