当前位置:网站首页>Shell -- -- -- -- -- - common gadgets, sort and uniq, tr, the cut
Shell -- -- -- -- -- - common gadgets, sort and uniq, tr, the cut
2022-08-09 16:02:00 【....yc】
shell------常用小工具,sort,uniq,tr,cut
一、cut:列截取工具
cut command to cut bytes from each line of the file,字符和字段并将这些字节,字符和字段写至标准输出.
如果不指定file参数,cut命令将读取标准输入.必须指定 -b,-c 或者 -f 标志之一.
选项:
| -b | 按字节截取 |
|---|---|
| -c | 按字符截取,常用于中文 |
| -d | 指定以什么为分隔符截取,默认为制表符 |
| -f | 通道和-d一起 |





二、sort Content sorting tool
是一个以行为单位对文件内容进行排序的工具,也可以根据不同的数据类型来排序.For example, data and character ordering are not the same.
格式:
sort [选项] 参数
常用选项:
| -t | 指定分隔符,默认使用TAB或空格分隔 |
|---|---|
| -k | 指定排序区域,那个区间排序 |
| -n | 按照数字进行排序,默认是以文字形式排序 |
| -u | 等同于uniq,Indicates that only one line is displayed for the same number,主要:如果行尾有空格去重就不成功 |
| -r | 反向排序,默认是升序 -r就是降序 |
| -o | 将排序后的结果转存至指定文件 |
Without any options, the first row is in ascending order by default,字母的话就是从a到z由上

以冒号为分隔符,以数字大小对第三列排序(升序)


Will output the result off the screen,输出到指定文件夹

三 ,uniq
Mainly used to deduplicate consecutive repeated lines
注意:是连续的行,所以通常和sortCombined with the first sort to make it into a continuous line and then to perform the deduplication operation,Otherwise, he cannot deduplicate discontinuous repeated lines.
格式:
uniq [选项] 参数
常用选项:
| -c | 对重复的行进行计数 |
|---|---|
| -d | 仅显示重复的行 |
| -u | 仅显示出现一次的行 |

仅显示出现一次的行

四、tr
He can substitute one character for another.或者可以完全除去一些字符.也可以用它来除去重复字符
格式:
用法:tr [选项] SET1 [SET2]
从标准输入中替换,缩减或删除字符,并将结果写到标准输出
常用选项:
| -d | 删除字符 |
|---|---|
| -s | Delete all repeated characters,只保留第一个 |




659955965074)]
[外链图片转存中…(img-KVkhgIVv-1659955965074)]
[外链图片转存中…(img-5X3WKpn0-1659955965075)]

边栏推荐
猜你喜欢

【DevOps】jekinsBuild step 'Execute shell' marked build as failure

参考文献格式

MySQL 原理与优化:Limit 查询优化

DSPE-PEG-Hydrazide,DSPE-PEG-HZ,磷脂-聚乙二醇-酰肼MW:1000

下班后用微信工作发病是否属于工伤?法院这样判

物联网技术概论:1~7章汇总(西安交通大学)

和月薪5W的测试聊过后,才知道自己一直在打杂...

spacedesk-notebook, tablet, extended screen-solve the problem that the tablet font is too small

Anaconda3安装后无法启动,启动闪退 2020-9

Jmeter性能测试步骤入门
随机推荐
【DevOps】jekins配置(二)
After reading the "Redis In-depth Notes" compiled by Tencent bosses in 90 days, I worshipped on the spot.
Common sql records
道路标识信息 (RSI)
uniapp学习
玩转云端 | 天翼云电脑的百变玩法
FilenameFilter过滤文件名
Architect's learning experience summary
leetcode_jz
Jmeter性能测试步骤入门
Mongodb增加权限管理
[Database] How does Sqlserver backup the database regularly and clear it regularly
C语言程序设计笔记(浙大翁恺版) 第十三周:文件
SMI 与 Gateway API 的 GAMMA 倡议意味着什么?
6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!
正则表达式实战:最新豆瓣top250爬虫超详细教程
VSTO踩坑记录(2)- 运用outlook对象模型发送邮件
道路形态(道路要素)
基于FPGA的FIR滤波器的实现(3)—采用Filter Design & Analysis设计
实践数据湖iceberg 第三十九课 清理快照前后数据文件变化分析