当前位置:网站首页>shell wc (统计字符数量)的基本使用
shell wc (统计字符数量)的基本使用
2022-04-23 04:18:00 【猎人在吃肉】
wc
命令的功能为统计指定文件中的字节数、字数、行数, 并将统计结果显示输出。
语法
基本语法:
wc [选项] 文件名
选项含义:
选项参数 | 含义 |
---|---|
-l |
统计 行数 |
-m |
统计 字符数 |
-w |
统计 字数 |
-c |
统计 字节数 |
示例:
wc1.txt 内容如下:
1 2
34 5
你好
对 wc1.tx 进行统计,执行结果如下:
[java@localhost java_demo]$ wc -l wc1.txt
3 wc1.txt
[java@localhost java_demo]$ wc -m wc1.txt
12 wc1.txt
[java@localhost java_demo]$ wc -w wc1.txt
5 wc1.txt
[java@localhost java_demo]$ wc -c wc1.txt
16 wc1.txt
每行结尾的换行符也算一个字符,1个空格也算1个字符。
(1) -l
统计行数。
这个简单,略过。
(2) -m
统计 字符数
1个汉字就作为1个字符计算,结果是 4 + 5 + 3 = 12 。
(3) -w
统计字数。
1个字是1个word。
第1行,2个字;
第2行,34
表示一个字 ,共2个字,
第3行,你好
表示一个字,因此,2+2+1=5。
(4) -c
统计 字节数
采用UTF-8编码,一个汉字在这里被转换为3字节,
第1行是 4个字节,
第2行是 5个字节,
第3行是 7个字节,
结果是 4+5+7=16 。
wc -c
显示的结果是16 。
版权声明
本文为[猎人在吃肉]所创,转载请带上原文链接,感谢
https://xiaojin21cen.blog.csdn.net/article/details/117768522
边栏推荐
- MYSQL去重方法汇总
- 无线充电全国产化电子元件推荐方案
- 【测绘程序设计】坐标反算神器V1.0(附C/C#/VB源程序)
- Who will answer the question?
- Basic introduction to spot gold
- AWS EKS 部署要点以及控制台与eksctl创建的差异
- STM32 MCU ADC rule group multi-channel conversion DMA mode
- MYSQL50道基础练习题
- How to regulate intestinal flora? Introduction to common natural substances, probiotics and prebiotics
- PHP export excel table
猜你喜欢
Xshell、Xftp连接新创建的Unbutu系统虚拟机全流程
Set classic topics
单片机串口数据处理(2)——uCOSIII+循环队列接收数据
Thought of reducing Governance -- detailed summary of binary search
Does China Mobile earn 285 million a day? In fact, 5g is difficult to bring more profits, so where is the money?
Gut liver axis: host microbiota interaction affects hepatocarcinogenesis
使用大华设备开发行AI人流量统计出现时间不正确的原因分析
[AI vision · quick review of robot papers today, issue 32] wed, 20 APR 2022
Common string processing functions in C language
[AI vision · quick review of today's sound acoustic papers issue 1] Thu, 14 APR 2022
随机推荐
[AI vision · quick review of robot papers today, issue 28] wed, 1 Dec 2021
Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
VHDL语言实现32位二进制数转BCD码
[AI vision · quick review of NLP natural language processing papers today, issue 30] Thu, 14 APR 2022
[AI vision · quick review of NLP natural language processing papers today, issue 28] wed, 1 Dec 2021
[mapping program design] coordinate inverse artifact v1 0 (with C / C / VB source program)
matlab讀取多張fig圖然後合並為一張圖(子圖的形式)
Difference between LabVIEW small end sequence and large end sequence
What is software acceptance testing? What are the benefits of acceptance testing conducted by third-party software testing institutions?
Cause analysis of incorrect time of AI traffic statistics of Dahua Equipment Development Bank
[echart] démarrer avec echart
Overview of knowledge map (II)
MYSQL50道基础练习题
Matlab reads multiple fig graphs and then combines them into one graph (in the form of sub graph)
Gut liver axis: host microbiota interaction affects hepatocarcinogenesis
Mysql---数据读写分离、多实例
QtSpim手册-中文翻译
Matlab minimalist configuration of vscode configuration
Basic introduction to spot gold
Leetcode->1 两数之和