当前位置:网站首页>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)]
边栏推荐
猜你喜欢
[Serilog] Simple .NET logging with fully structured events
Jmeter性能测试步骤入门
leetcode 剑指 Offer 07. 重建二叉树
After reading the "Redis In-depth Notes" compiled by Tencent bosses in 90 days, I worshipped on the spot.
MySQl表的增删查改(聚合查询+联合查询)
Refuse to "reinvent the wheel", Baidu EasyDL lets you play with AI custom development
vivo手机上的系统级消息推送平台的架构设计实践
暴雨天,看天翼云如何“快准稳”防涝
实践数据湖iceberg 第三十八课 spark sql, Procedures语法进行数据治理(小文件合并,清理快照)
985测试工程师被吊打,学历和经验到底谁更重要?
随机推荐
shell提取ip地址
C语言程序设计笔记(浙大翁恺版) 第十二周:程序结构
How does the JVM judge that an object is useless
【原神】手机版原神下错版本不能登录怎么办?B服修改为官服
半自动爬虫
Common sql records
After reading the "Redis In-depth Notes" compiled by Tencent bosses in 90 days, I worshipped on the spot.
测试工程师,看不上年薪20w,原因居然是...
【OpenGL】四、OpenGL入门总结:LearnOpenGL CN教程中关于欧拉角公式推导
985测试工程师被吊打,学历和经验到底谁更重要?
[DevOps] jekins deployment (1)
WebShell简介
DSPE-PEG-Hydrazide,DSPE-PEG-HZ,磷脂-聚乙二醇-酰肼MW:1000
BVT测试(版本验证测试、冒烟测试)和Daily build
C语言程序设计笔记(浙大翁恺版) 第八周:数组
基于FPGA的FIR滤波器的实现(2)—采用kaiserord & fir2 & firpm函数设计
刷完这174道Android开发面试题,搞懂所有技术栈
C语言——函数、参数和指针
【Message Center】Architecture Preparation
golang中的select原理解析