当前位置:网站首页>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)]

边栏推荐
猜你喜欢
随机推荐
Refuse to "reinvent the wheel", Baidu EasyDL lets you play with AI custom development
[DevOps] jekins configuration (2)
由于谷歌版本自动更新,导致selenium项目报错,如何关闭谷歌浏览器的自动更新?
【LeetCode】1413. 逐步求和得到正数的最小值
MySQL 原理与优化:Limit 查询优化
DSPE-PEG-Hydrazide,DSPE-PEG-HZ,磷脂-聚乙二醇-酰肼MW:1000
SQL Server查询优化
benchmark性能测试
概率论基础知识整理 | 概率论的基本概念
玩转云端 | 天翼云电脑的百变玩法
Redis 面试题
BVT测试(版本验证测试、冒烟测试)和Daily build
shell------常用小工具,sort,uniq,tr,cut
FilenameFilter过滤文件名
技术分享 | 接口自动化测试如何处理 Header cookie
概率论基础知识整理 | 随机向量
项目小操作:form表单的校验,以及第二次显示提示校验内容等问题
DMPE-PEG-Mal Maleimide-PEG-DMPE 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
【磁场建模项目2020-02-Lilin】采集板硬件规范
代码随想录笔记_动态规划_377组合总和IV








