当前位置:网站首页>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
边栏推荐
- 线程间控制之Semaphore使用介绍
- IE8 browser prompts whether to block access to JS script
- 循环队列的基本操作(实验)
- Get the thread return value. Introduction to the use of future interface and futuretask class
- Golang 对分片 append 是否会共享数据
- 一些小小小小记录~
- 如何轻松做好一个项目
- 本以为能躺着进华为,结果陆续收到京东/滴滴/爱奇艺offer的我迷茫了
- JS progress bar, displaying the loading progress
- Pass in external parameters to the main function in clion
猜你喜欢
随机推荐
MySQL lock database lock
dp-能量项链
About the configuration and use of json5 in nodejs
逻辑卷创建与扩容
矩阵交换行列
js 键值判断
修改Firebase Emulators的默认侦听IP
Date的after时间判断
顺序栈的基本操作
source insight via samba
tcp_diag 内核相关实现 1 调用层次
Returns the subscript after array sorting
DP - [noip2000] grid access
AT89C52单片机的频率计(1HZ~20MHZ)设计,LCD1602显示,含仿真、原理图、PCB与代码等
ie8 浏览器提示是否 阻止访问js脚本
关于UDP接收icmp端口不可达(port unreachable)
浅谈skiplist在LevelDB的应用
Redis源码分析之PSYNC同步
微信小程序轮播图swiper
JDBC details