当前位置:网站首页>Sed learning for application
Sed learning for application
2022-04-23 14:22:00 【Small ash pier】
1、 Delete centos7 System /etc/grub2.cfg All the white space characters at the beginning of the line that start with white space in the file .
# sed -nr 's/^[[:blank:]]+//p' /etc/grub2.cfg
2、 Delete /etc/fstab All # start , The first line of a line followed by at least one white space character # And white space characters .
# sed -nr 's/^#[[:blank:]]+(.*)/\1/p' /etc/fstab
3、 stay centos6 System /root/install.log Add... At the beginning of each line # Number .
# sed -nr 's/(.*)/#\1/p' /root/install.log
4、 stay /etc/fstab The document does not contain # The beginning of the first line increases # Number .
# sed -nr '/^#/!p' /etc/fstab |sed -nr 's/.*/#&/p'
# sed -nr 's/^[^#]/#/p' /etc/fstab
5、 Handle /etc/fstab route , Use sed Command to extract its directory name and base name .
# echo /etc/fstab |sed -nr 's@(^\/.*\/)(.*)@\2@p'
fstab
# echo /etc/fstab |sed -nr 's@(^\/.*\/)(.*)@\1@p'
/etc/
6、 utilize sed Take out ifconfig In the command IPv4 Address .
# ifconfig eth0 |sed -nr 's/.*inet (.*) netmask.*/\1/p'
7、 Statistics centos In the installation CD Package All under directory rpm The purpose of the document is to . The number of repetitions that separate the penultimate field
# ls *.rpm|sed -r 's@^.*\.([^.]+)\.rpm$@\1@'|sort|uniq -c
# ls *.rpm |sed -nr 's@.*\.(.*)\.rpm$@\1@p' |sort|uniq -c
8、 Statistics /etc/init.d/functions The number of occurrences of each word in the file , And sort ( use grep and sed The two methods are implemented separately )
# grep -o '\<[a-zA-Z]\{2,\}\>' /etc/init.d/functions |sort |uniq -c |sort -nr
# sed -r 's/[^[:alpha:]]/\n/g' /etc/init.d/functions |sort |uniq -c |sort -nr
9、 Put the text file's n and n+1 The rows merge into one ,n For odd lines
# seq 10 | sed "1~2N;s/\n/ /"
版权声明
本文为[Small ash pier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231409158691.html
边栏推荐
- 基础正则表达式
- API Gateway/API 网关(二) - Kong的使用 - 负载均衡Loadbalance
- gif转为静态图片处理
- Preview CSV file
- 快速搞懂线程实现的三种方式
- JS parabola motion packaging method
- C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【2】
- 处理 mkdir:无法创建目录“aaa“:只读文件系统
- C语言p2选择分支语句详解
- Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
猜你喜欢

MYSQL一种分表实现方案及InnoDB、MyISAM、MRG_MYISAM等各种引擎应用场景介绍

C语言知识点精细详解——初识C语言【1】

MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等

查找水仙花数-for循环实践

線程組ThreadGroup使用介紹+自定義線程工廠類實現ThreadFactory接口

差分隐私(背景介绍)

After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items

在Clion中给主函数传入外部参数

顺序表的操作,你真的学会了吗?

krpano全景之vtour文件夹和tour
随机推荐
redis 模块编程中 key value的生命周期
C语言知识点精细详解——初识C语言【1】
Man man notes and @ reboot usage of crontab
JS key value judgment
krpano全景之vtour文件夹和tour
dp-[NOIP2000]方格取数
流程控制之分支语句
ActiveMQ Basics
Qt实战:云曦聊天室篇
Redis源码分析之PSYNC同步
x509证书cer格式转pem格式
Use the executors class to quickly create a thread pool
js 格式化时间
循环队列的基本操作(实验)
返回数组排序后下标
Quickly understand the three ways of thread implementation
DP - [noip2000] grid access
编译Openssl
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
C语言知识点精细详解——初识C语言【1】——你不能不知的VS2022调试技巧及代码实操【2】