当前位置:网站首页>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
边栏推荐
- kprobe 的 3 种使用
- 关于UDP接收icmp端口不可达(port unreachable)
- 拨开云雾synchronized使用五种方式介绍
- On the problem of cliff growth of loss function in the process of training
- 分分钟掌握---三目运算符(三元运算符)
- mysql锁数据库锁
- MYSQL一种分表实现方案及InnoDB、MyISAM、MRG_MYISAM等各种引擎应用场景介绍
- 01-nio basic ByteBuffer and filechannel
- 字节面试编程题:最小的K个数
- Use the executors class to quickly create a thread pool
猜你喜欢
随机推荐
DP - [noip2000] grid access
一篇博客让你学会在vscode上编写markdown
MySQL同步Could not find first log file name in binary log index file错误
API Gateway/API 网关(四) - Kong的使用 - 集成Jwt和熔断插件
source insight via samba
JS key value judgment
TLS/SSL 协议详解 (30) SSL中的RSA、DHE、ECDHE、ECDH流程与区别
网页自适应,等比缩放
剑指offer刷题(1)--面向华为
JS recursion (1)
差分隐私(背景介绍)
如何5分钟上手使用OCR
DP energy Necklace
C语言知识点精细详解——初识C语言【1】
elk安装
JS progress bar, displaying the loading progress
返回数组排序后下标
统信UOS卸载php7.2.24,安装php7.4.27 ;卸载再安装为PHP 7.2.34
Use the executors class to quickly create a thread pool
MQ-2和DS18B20的火灾温度-烟雾报警系统设计,51单片机,附仿真、C代码、原理图和PCB等