当前位置:网站首页>Quickly master the sort command and tr command
Quickly master the sort command and tr command
2022-07-19 07:02:00 【I'm Zha Zha Hui】
List of articles
sort command

Given the file num.txt, args.txt
The contents of the document :num.txt
1
3
5
2
4
The contents of the document :args.txt
test
args1
args2
args4
args4
args3
1、 Yes num.txt Sort , And output the results to sorted_num.txt in
[[email protected] ~]# sort num.txt > sorted_num.txt
[[email protected] ~]# more num.txt
1
3
5
2
4
[[email protected] ~]# more sorted_num.txt
1
2
3
4
5
2、 Yes args.txt Sort , And output the results to sorted_args.txt in
[[email protected] ~]# sort args.txt > sorted_args.txt
[[email protected] ~]# more sorted_args.txt
args1
args2
args3
args4
args4
test
3、 Yes num.txt and args.txt Sort , And output the results to sorted_merge.txt in
[[email protected] ~]# sort num.txt args.txt > sorted_merge.txt
[[email protected] ~]# more sorted_merge.txt
1
2
3
4
5
args1
args2
args3
args4
args4
test
4、 Yes args.txt After sorting, de re output
[[email protected] ~]# sort -u args.txt
args1
args2
args3
args4
test
5、 Merge sorted_args.txt and sorted_num.txt And output
[[email protected] ~]# cat sorted_args.txt sorted_num.txt
args1
args2
args3
args4
args4
test
1
2
3
4
5
Given the file info_txt: Press the second column as key Sort
No Name Score
1 zhang 20
2 li 80
3 wang 90
4 sun 60
[[email protected] ~]# sort -k 2 info_txt
2 li 80
No Name Score
4 sun 60
3 wang 90
1 zhang 20
tr command
tr Instruction reads data from standard input , After replacement or deletion , Output the results to standard output .
grammar : tr [OPTION]…SET1[SET2]
Parameter description :
-c Invert set character . That is to say, it conforms to SET1 Don't deal with the part of , The rest of the non conformity is converted
-d Delete instruction characters
-s Reduce the number of consecutive characters to a specified single character
List :
1、 take 26 After a lowercase letter 13 Replace the first letter with a capital letter
[[email protected] ~]# echo qwertyuiopasdfghjklzxcvbnm | tr j-z J-Z
QWeRTYUiOPaSdfghJKLZXcVbNM
2、 take hello 123 world 456 Replace the numbers in with empty characters
[[email protected] ~]# echo 'hello 123 world 456' | tr 0-9 ' '
hello world
[[email protected] ~]# echo 'hello 123 world 456' | tr -s 0-9 ' '
hello world
[[email protected] ~]# echo 'hello 123 world 456' | tr -d 0-9
hello world
3、 take hello 123 world 456 Replace letters and spaces in , Just keep the numbers
[[email protected] ~]# echo 'hello 123 world 456' | tr -cd 0-9
123456
边栏推荐
猜你喜欢

银河麒麟服务器系统搭建本地和局域网yum源

mysql的复习总结

Good partner of single chip microcomputer - CS Genesis SD NAND flash

103.53.124.X IP段BGP线路和普通的专线有什么区别

快速掌握sort命令,tr命令

What is tsd/qsd? What is CS Genesis SD NAND?

Comparison between CS brand SD NAND and SPI NAND

The use and differences of dictionaries, tuples and lists,

Tianyi cloud Hangzhou virtual machine (VPS) performance evaluation

Zuul路由的映射规则配置
随机推荐
[untitled]
论文阅读:Deep Residual Shrinkage Networksfor Fault Diagnosis
搭建一个网站都需要那些东西
Freebsd 12 安装RPM包
Personal information management system
Xiaodi network security - Notes (2)
ACK攻击是什么意思?ACK攻击怎么防御
个人信息管理系统
快速理解重定向
PyTorch学习日记(四)
Sed command of text three swordsman -- text replacement; Grep command - text filtering
About file upload and download
Redraiment的遭遇
Tower of Hanoi 2 (function)
解决sonar的单元测试的覆盖率会为0问题
Closures and decorators
企业或个人域名备案怎么弄
pytorch张量
edit关闭保存时自动生成配置文件
ARM服务器搭建 我的世界(MC) 1.18.2 版私服教程