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

news/2024/7/7 21:04:25 标签: linux, 运维, 服务器, word count, lines

文章目录

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

1、wc -l

在命令 wc -l 中,-l 的英文全称是 lines。这个选项用于指定 wcword 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 ~]# 

在这里插入图片描述


http://www.niftyadmin.cn/n/5535206.html

相关文章

上位机图像处理和嵌入式模块部署(mcu项目1:实现协议)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 这种mcu的嵌入式模块理论上都是私有协议&#xff0c;因为上位机和下位机都是自己开发的&#xff0c;所以只需要自己保证上、下位机可以通讯上&…

Python数据分析案例47——笔记本电脑价格影响因素分析

案例背景 博主对电脑的价格和配置一直略有研究&#xff0c;正好最近也有笔记本电脑相关的数据&#xff0c;想着来做点分析吧&#xff0c;写成一个案例。基本上描述性统计&#xff0c;画图&#xff0c;分组聚合&#xff0c;机器学习&#xff0c;交叉验证&#xff0c;搜索超参数…

大模型提问中包括时间的实战方案

大家好,我是herosunly。985院校硕士毕业,现担任算法研究员一职,热衷于机器学习算法研究与应用。曾获得阿里云天池比赛第一名,CCF比赛第二名,科大讯飞比赛第三名。拥有多项发明专利。对机器学习和深度学习拥有自己独到的见解。曾经辅导过若干个非计算机专业的学生进入到算法…

action-setup出现pnpm (ERR_INVALID_THIS)异常在pnpm v8和node.js v20

在使用github actions部署博客时,突然出现以下报错: pnpm 版本 8.15.7 node.js 版本 v20.12.2 WARN  GET https://registry.npmjs.org/pnpm error (ERR_INVALID_THIS). Will retry in 10 seconds. 2 retries left.WARN  GET https://registry.npmjs.org/pnpm error (ERR_INVA…

golang解析配置文件

首先定义一个原始的yaml配置文件. mysql:host: 127.0.0.1port: 3306db: gvb_dbuser: rootpassword: rootLogLevel: devdefaultStringSize: 256disableDatetimePrecision: truedontSupportRenameIndex: truedontSupportRenameColumn: trueskipInitializeWithVersion: falselogg…

鸿蒙如何打包应用程序

总结鸿蒙应用程序包 之前文章详细讲解了关于三种程序包的内容&#xff0c;现在简单总结一下&#xff1a; 1. 总结 首先需要搞清楚鸿蒙项目的模块Module的分类: Module分为“Ability”和“Library”两种类型 HAP HAP: Harmony Ability Package , 叫做鸿蒙Ability包。 “Abil…

Elasticsearch8.x Spring Data and Spring Boot 3 尝鲜

在本教程中,我们将通过实际操作和实用的方式,探索使用 Spring Boot 进行 Elasticsearch 的基础知识。我们将学习如何使用 Spring Data Elasticsearch 模块创建索引、进行 CRUD 操作、搜索和查询 Elasticsearch 文档。我们还将看看如何在我们的 Spring 应用程序中记录 Elastic…

算法训练(leetcode)第二十二天 | 491. 非递减子序列、全排列、47. 全排列 II

刷题记录 491. 非递减子序列46. 全排列47. 全排列 II去重写法一去重写法二 491. 非递减子序列 leetcode题目地址 本题对于去重是一个难点&#xff0c;因为题目不允许排序&#xff0c;所以需要加一个笔记数组来判断相同的元素在同一层是否已经使用。使用set、map都可以达到这个…