当前位置:网站首页>快速学会cut命令,uniq命令的使用
快速学会cut命令,uniq命令的使用
2022-07-17 05:22:00 【我是渣渣辉】
cut命令使用

例如:
给定文件cut_data.txt且内容为:
No Name Score
1 zhang 20
2 li 80
3 wang 90
4 sun 60
1、 使用默认定界符切割文件内容,且输出切割后的第一个字段
[[email protected] ~]# cut -f 1 cut_data.txt
No Name Score
1 zhang 20
2 li 80
3 wang 90
4 sun 60
2、切割文件内容,且输出切割后的第一个字段和第三个字段
[[email protected] ~]# cut -d' ' -f 1,3 cut_data.txt
No Score
1 20
2
3 90
4
[[email protected] ~]#
3、按字节切割:输出切割的第一个字节到第10个字节的内容
[[email protected] ~]# cut -b -10 cut_data.txt
No Name Sc
1 zhang 20
2 li 80
3 wang 90
4 sun 60
[[email protected] ~]#
4、按字符切割:输出切割后的第一个字符和第5个字符的内容
[[email protected] ~]# cut -c 1,5 cut_data.txt
Na
1a
2
3n
4n
[[email protected] ~]#
5、按指定分界符去切割:内容如下, 输出第一个字段和第三个字段内容
No|Name|Score
1|zhang|20
2|li|80
3|wang|90
4|sun|60
[[email protected] ~]# cut -d'|' -f 1,3 cut_data.txt
No|Score
1|20
2|80
3|90
4|60
[[email protected] ~]#
uniq命令使用

新建文件uniq_data.txt,文件内容为
Welcome to Linux
Windows
Windows
Mac
Mac
Linux
1、使用uniq命令输出去重后的结果
[[email protected] ~]# uniq -i uniq_data.txt
Welcome to Linux
Windows
Mac
Linux
2、使用uniqmingl只输出重复的行
[[email protected] ~]# uniq --all-repeated uniq_data.txt
Windows
Windows
Mac
Mac
3、使用uniq命令输出不重复的行
[[email protected] ~]# uniq -u uniq_data.txt
Welcome to Linux
Linux
4、使用uniq命令统计重复次数
[[email protected] ~]# uniq -c uniq_data.txt
1 Welcome to Linux
2 Windows
2 Mac
1 Linux
边栏推荐
- 小迪网络安全-笔记(2)
- Comparison of advantages and disadvantages between SD NAND and EMMC
- Steam游戏服务器配置选择 IP
- Wu Enda machine learning chapter 12-13
- What is tsd/qsd? What is CS Genesis SD NAND?
- Tcp/ip protocol learning
- Intranet penetration server building tutorial, NPs use tutorial
- ssh远程登录服务
- opensuse 安装网易云音乐(tumbleweed)(leap)
- Tianyi cloud Hangzhou virtual machine (VPS) performance evaluation
猜你喜欢
![[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[CS Genesis] comparative analysis of advantages and disadvantages of SD NAND and raw NAND

Intranet penetration server building tutorial, NPs use tutorial

Minecraft Paper 1.18.1 版开服教程,我的世界开服教程,MCSManager9面板使用教程

Arm server building my world (MC) version 1.18.2 private server tutorial

SSH remote login service

ssh远程登录服务

传奇手游怎么开服?需要投资多少?需要那些东西?

Application case of CS brand sdnand in color detector industry

Performance evaluation and comparison of Huawei cloud Kunpeng arm ECs and x86 ECS

通过数据加密方案阻止勒索攻击
随机推荐
Slag learning road (2) pure white direction: win Server 2003 server building
mysql的复习总结
How to make good use of cost compensation contract in government procurement
Comparison between CS brand SD NAND and SPI NAND
Slag learning path (1) output the calendar page of a certain month of a certain year
Xiaodi network security - Notes (3)
勒索病毒防护浅谈
University
Commande awk du troisième épéiste - - interception
What is data center?
传奇怎么开服?开传奇私服需要准备什么呢?
华为云 鲲鹏ARM云服务器 和 x86云服务器 性能评测对比
Évaluation des performances de la machine virtuelle Tianyi Cloud Hangzhou (VPS)
Thales安全解决方案:怎么提高国家网络安全的关键步骤
Loadng class `com. mysql. jdbc. Driver‘. This is deprecated. The new driver class is `com. mysql. cj. jdb
Temperature acquisition experiment and experimental experience based on I2C
轻重搭配(贪心)
Escape from the center of the lake (math problem)
Tcp/ip four layer model and related configurations of F5
小迪-网络安全 笔记(1)