当前位置:网站首页>快速学会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
边栏推荐
- notepad++下划线以及大小写字母置换
- Technical specification for secure electronic signature and password gm/t 0031 | GB / T 38540 format OpenSSL package analysis
- Commande awk du troisième épéiste - - interception
- 【自动化测试】——robotframework实战(二)新建测试用例
- Hermit crab and anemone
- 中国知网论文free下载的方法
- Intranet penetration server building tutorial, NPs use tutorial
- 【自动化测试】——robotframework实战(一)搭建环境
- 我的世界 1.18.1 Forge版 开服教程,可装MOD,带面板
- Maomao goes to work (recursive)
猜你喜欢

STM32 serial communication related learning

SSH remote login service

开发板训练:STM32下的多任务程序

Double code time scale network diagram

IP103.53.125.xxx IP地址段 详解

How to determine the electronic gear ratio of servo motor?

Ucloud Shanghai arm cloud server evaluation

Information on successful cooperation between CS brand sdnand and stm32mcu

STEAM游戏高主频i9-12900k 搭建CS:GO服务器

5G时代服务器在这里面起着什么作用?
随机推荐
Xiaodi - network security notes (1)
小迪网络安全-笔记(5)
天翼云 杭州 云主机(VPS) 性能评测
手动字符串比较(指针题)
上课啦要点名啊
Weight matching (greedy)
Decipher password (comprehensive)
day01(Flume)
阿里云 杭州 ARM 云服务器性能评测
What happened to redraiment
Application case of CS brand SD NAND in air quality inspection industry
Personal information management system
Learning about STM assembler design
How to determine the electronic gear ratio of servo motor?
ANAME
How to make good use of cost compensation contract in government procurement
5G时代服务器在这里面起着什么作用?
华为云 鲲鹏ARM云服务器 和 x86云服务器 性能评测对比
传奇游戏架设教程
Postage range (array or + function)