•        OS : openKylin-0.7.5-x86_64
  •        blog : 师万物

ls wc 统计目录下的文件数

sww@sww:~$ ls /home/sww/
2022-10-09_20-35-28.png  图片  桌面.7z            out_1.txt
2022-10-09_21-17-13.png  文档  a                  out.txt
公共的                   下载  err.txt            path.txt
模板                     音乐  find_user_sww.txt
视频                     桌面  ls.txt
sww@sww:~$ ls /home/sww/ | wc -w
18

wc

root@sww:~# wc /etc/shadow
  35   35 1104 /etc/shadow
root@sww:~# wc -c /etc/shadow
1104 /etc/shadow
root@sww:~# wc -l /etc/shadow
35 /etc/shadow
root@sww:~# wc -m /etc/shadow
1104 /etc/shadow
root@sww:~# wc -w /etc/shadow
35 /etc/shadow
root@sww:~# wc -L /etc/shadow
129 /etc/shadow

root@sww:~# wc --help
用法:wc [选项]... [文件]...
 或:wc [选项]... --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.

如果没有指定文件,或者文件为"-",则从标准输入读取。

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		显示此帮助信息并退出
      --version		显示版本信息并退出

GNU coreutils 在线帮助:<https://www.gnu.org/software/coreutils/>
请向 <http://translationproject.org/team/zh_CN.html> 报告 wc 的翻译错误
完整文档请见:<https://www.gnu.org/software/coreutils/wc>
或者在本地使用:info '(coreutils) wc invocation'

学习资源


感恩曾经帮助过 师万物 的同学们。