当前位置:网站首页>Regular and sed exercises
Regular and sed exercises
2022-07-27 07:40:00 【Empty and white】
One 、 Regular
1、 Show /etc/rc.d/rc.sysinit File with size insensitive h Beginning line ;
grep -i "^h" /etc/rc.d/rc.sysinit
2、 Show /etc/passwd China and Israel sh The line at the end ;
grep sh$ /etc/passwd
3、 Show /etc/fstab China and Israel # start , One or more whitespace characters followed by , And then it's followed by any non whitespace line ;
grep -E "^# +[^[:space:]]+" /etc/fstab
4、 lookup /etc/rc.d/rc.local Contained in the “ With to Start with to ending ” Word serial of ;
grep "^to.*to$" /etc/rc.d/rc.local
5、 lookup /etc/inittab contains “ With s start , And d Ending words ” Pattern line ;
grep -w "\<s[a-Z]*d\>" /etc/inittab
6、 lookup ifconfig In the command result 1-255 Integer between ;
ifconfig | grep -oE "\<[1-9]|1[0-9][0-9]|2[0-4][1-9]|25[0-5]\>"
7、 Show /var/log/secure The file contains “Failed” or “FAILED” The line of ;
grep -E "(Faild|FAILED)" /var/log/secure
8、 stay /etc/passwd Take out the default shell by bash The line of ;
grep bash$ /etc/passwd
9、 List... In long format /etc/ Directory to ns start 、.conf File information at the end ;
ll /etc | awk '{print $NF }'|grep -E "^(ns).*\.(conf)$"
10、 Highlight passwd Colon in file , And the characters on both sides ;
grep -E "(.:+.)" /etc/passwd
Two 、sed
1、 Delete /etc/grub2.conf All the white space characters at the beginning of the line that start with white space in the file
sed 's/^ \+//' /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 -r 's/^# \+//' /etc/fstab
3、 stay /root/install.log Add... At the beginning of each line # Number
sed 's/^.*/#&/' /etc/fstab
4、 stay /etc/fstab The document does not contain # The beginning of the first line increases # Number
sed 's/^[^#]/#&/' /etc/fstab
5、 utilize sed Take out ifconfig In the command IPv4 Address
ifconfig | sed -n 2p | sed 's/ *inet//' | sed 's/ net.*//'
6、 Turn off the machine SELinux The function of
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
7、 stay /etc/hosts Add content to the configuration file
sed -i '1 i 192.168.198.1' /etc/hosts
边栏推荐
- [golang learning notes 2.0] arrays and slices in golang
- Gossip: Recently, many friends talk about going abroad
- 【StoneDB Class】入门第一课:数据库知识科普
- flink原理(一) 状态的TTL管理、容错机制
- RestTemplate 连接池配置
- 什么是真正的 HTAP ?(二)挑战篇
- 什么是真正的HTAP?(一)背景篇
- Understanding and learning of properties class and properties configuration file
- ClickHouse 笔记1 | 简介、特点 | 基于CentOS7系统的安装与使用 | 常用数据类型 | MergeTree 表引擎 | SQL操作
- 【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
猜你喜欢

闭散列和开散列解决哈希冲突

连接MySQL时报错:Public Key Retrieval is not allowed 【解决方法】

A small cotton padded jacket with air leakage

C language programming | program compilation and preprocessing

我是不是被代码给耽误了……不幸沦为一名程序员……

Single arm routing (explanation + experiment)

Flink1.14 SQL basic syntax (I) detailed explanation of Flink SQL table query

drawImage方法第一次调用不显示图片的解决方式

mysql备份策略

MySQL backup strategy
随机推荐
电子量产项目框架--基本思想
Tcp/ip protocol analysis (tcp/ip three handshakes & four waves + OSI & TCP / IP model)
我是不是被代码给耽误了……不幸沦为一名程序员……
What are the main threads of Youxuan database?
Turn off the auto start function of Oracle service in centos7
ADC噪声全面分析 -02- ADC 噪声测量方法和相关参数
Demonstrate the use of foreign keys with Oracle
【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
模仿大佬制作的宿舍门禁系统(三)
[QT] unable to open the containing file pcap.h (C1083) in QT creator
Analysis of query results using both left join on and where in MySQL
mysql备份策略
Introduction to network -- overview of VLAN and trunk
Shell condition test, judgment statement and operator of shell system learning
【QT】capture. Obj:-1: error: lnk2019: unresolved external symbols__ imp_ Htons (solution)
[wsl2] configure the USB camera connecting the USB device and using the host
Debug:与泛型有关的“无法解析的外部符号”
小程序支付管理-新版支付对接流程
SQL statement batch update time minus 1 day
Quickly update the information in a field in kettle