当前位置:网站首页>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
边栏推荐
猜你喜欢
本以为能躺着进华为,结果陆续收到京东/滴滴/爱奇艺offer的我迷茫了
C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
C语言知识点精细详解——初识C语言【1】
51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
爬虫练习题(一)
Logback logger and root
MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等
Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
A table splitting implementation scheme of MySQL and InnoDB, MyISAM and MRG_ Introduction to MyISAM and other engine application scenarios
在Clion中给主函数传入外部参数
随机推荐
流程控制之分支语句
source insight via samba
js 格式化时间
Use cases of the arrays class
MYSQL一种分表实现方案及InnoDB、MyISAM、MRG_MYISAM等各种引擎应用场景介绍
进入新公司,运维工程师从下面这几项了解系统的部署
KVM learning resources
初识STL
Docker (V) MySQL installation
Five ways of using synchronized to remove clouds and fog are introduced
剑指offer刷题(1)--面向华为
DP energy Necklace
MySQL同步Could not find first log file name in binary log index file错误
在电视屏幕上进行debug调试
How to do a project easily
Get the thread return value. Introduction to the use of future interface and futuretask class
百度笔试2022.4.12+编程题目:简单整数问题
asp.net使用MailMessage发送邮件的方法
关于UDP接收icmp端口不可达(port unreachable)
Pass in external parameters to the main function in clion