当前位置:网站首页>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
边栏推荐
- ADC噪声全面分析 -01- ADC噪声的类型以及ADC特性
- opengl-shader学习笔记:varying变量
- Use Amazon dynamodb and Amazon S3 combined with gzip compression to maximize the storage of player data
- SQL statement batch update time minus 1 day
- The first open source MySQL native HTAP database in China will be released soon! Look at the three highlights first, limited to the surrounding areas, waiting for you~
- Panabit SNMP configuration
- shell企业面试题练习
- C language implementation of guessing numbers Games project practice (based on srand function, rand function, switch statement, while loop, if condition criterion, etc.)
- Analysis of query results using both left join on and where in MySQL
- Drconv pytorch is changed to the same size of output and input
猜你喜欢

Zabbix: map collected values to readable statements

Quickly update the information in a field in kettle

Okaleido生态核心权益OKA,尽在聚变Mining模式

Expose Prometheus metrics in Perl programs

杂谈:最近好多朋友谈出国……

Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community

杂谈:高考

Graylog 日志服务器单节点部署

Understanding and learning of node flow and processing flow in io

闭散列和开散列解决哈希冲突
随机推荐
Oracle composite query
Installation and use of apifox
Use Popen to execute a command and get the return result
UI gesture actions of uiautomator common classes
Plato farm is expected to further expand its ecosystem through elephant swap
Record a pit dug by yourself~
Regular expression foundation sorting
次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
flink原理(一) 状态的TTL管理、容错机制
Array method and loop in JS
Quickly update the information in a field in kettle
A small cotton padded jacket with air leakage
Okaleido ecological core equity Oka, all in fusion mining mode
Temperature and humidity measurement and display device based on Arduino
The difference between critical section (the code that accesses critical resources in each thread) and mutex (mutex between processes, shared memory, virtual address)
Panabit SNMP configuration
flink中维表Join几种常见方式总结
C winfrom common function integration-2
Flink de duplication (I) summary of common de duplication schemes in Flink and Flink SQL
Closed hash and open hash resolve hash conflicts