当前位置: 首页> 游戏> 网游 > Linux命令 wc(word count)-l(lines)用于统计文件中的行数。

Linux命令 wc(word count)-l(lines)用于统计文件中的行数。

时间:2025/7/9 20:43:56来源:https://blog.csdn.net/m0_65152767/article/details/140051457 浏览次数:0次

文章目录

  • 1、wc -l
  • 2、实战
  • 3、wc --help

1、wc -l

在命令 wc -l 中,-l 的英文全称是 lines。这个选项用于指定 wc(word count,单词计数)命令来统计文件的行数。

例如,当你运行 wc -l load_user_100w_sort.sql 时,wc 会计算 load_user_100w_sort.sql 文件中的行数,并输出结果。

2、实战

[root@localhost ~]# ll
总用量 56504
-rw-------. 1 root root     1533 124 2023 anaconda-ks.cfg
-rw-r--r--. 1 root root      191 625 13:29 dump6379.rdb
-rw-r--r--. 1 root root      191 625 13:31 dump6380.rdb
-rw-r--r--. 1 root root      191 625 13:32 dump6381.rdb
-rw-r--r--. 1 root root      583 624 11:13 dump.rdb
-rw-r--r--. 1 root root     1564 124 2023 initial-setup-ks.cfg
-rw-r--r--. 1 root root 57650380 222 2022 load_user_100w_sort.sql
drwxr-xr-x. 3 root root       18 18 18:11 minio
-rw-r--r--. 1 root root      141 625 17:00 nodes-6379.conf
-rw-------. 1 root root   178567 63 13:50 nohup.out
drwxr-xr-x. 2 root root        6 124 2023 公共
drwxr-xr-x. 2 root root        6 124 2023 模板
drwxr-xr-x. 2 root root        6 124 2023 视频
drwxr-xr-x. 2 root root        6 124 2023 图片
drwxr-xr-x. 2 root root        6 124 2023 文档
drwxr-xr-x. 2 root root        6 124 2023 下载
drwxr-xr-x. 2 root root        6 124 2023 音乐
drwxr-xr-x. 2 root root        6 124 2023 桌面
[root@localhost ~]# wc -l load_user_100w_sort.sql 
1000000 load_user_100w_sort.sql
[root@localhost ~]# 

这表示 load_user_100w_sort.sql 文件中有 1,000,000 行(假设文件名中的 "100w" 是 "100万" 的缩写,即一百万)

3、wc --help

[root@localhost ~]# 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.  With no FILE, or when FILE is -,
read standard input.  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=文件        从指定文件读取以NUL 终止的名称,如果该文件被指定为"-"则从标准输入读文件名-L, --max-line-length 显示最长行的长度-w, --words                   显示单词计数--help            显示此帮助信息并退出--version         显示版本信息并退出GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告wc 的翻译错误
要获取完整文档,请运行:info coreutils 'wc invocation'
[root@localhost ~]# 

在这里插入图片描述

关键字:Linux命令 wc(word count)-l(lines)用于统计文件中的行数。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: