当前位置:网站首页>Sed, regular expression of shell programming
Sed, regular expression of shell programming
2022-07-29 09:47:00 【m0_ fifty-eight million nine hundred and sixty-three thousand o】
1、 Show /etc/rc.d/rc.sysinit File with size insensitive h Beginning line ;
[[email protected] test]# grep -E "^[h|H]" /etc/rc.d/rc.sysinit
2、 Show /etc/passwd China and Israel sh The line at the end ;
[[email protected] test]# 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 ;
[[email protected] test]# grep "^#[[:space:]]\{1,\}[^[:space:]]" /etc/fstab # /etc/fstab # Created by anaconda on Sat Jul 9 04:36:11 2022 # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file.
4、 lookup /etc/rc.d/rc.local Contained in the “ With to Start with to ending ” Word serial of ;
[[email protected] test]# grep "\(to\).*\1" /etc/rc.d/rc.local # In contrast to previous versions due to parallel execution during boot
5、 lookup /etc/inittab contains “ With s start , And d Ending words ” Pattern line ;
[[email protected] test]# grep "\<s[a-Z]*d\>" /etc/inittab # Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target # systemd uses 'targets' instead of runlevels. By default, there are two main targets:
6、 lookup ifconfig In the command result 1-255 Integer between ;
[[email protected] test]# ifconfig | grep -E "\<([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>" [[email protected] test]# ifconfig | grep -w "`seq 255`" inet 192.168.223.132 netmask 255.255.255.0 broadcast 192.168.223.255 inet6 fe80::20c:29ff:fe8f:6df2 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:8f:6d:f2 txqueuelen 1000 (Ethernet) RX packets 14634 bytes 14380402 (13.7 MiB) TX packets 9060 bytes 724182 (707.2 KiB) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> RX packets 12 bytes 1020 (1020.0 B) TX packets 12 bytes 1020 (1020.0 B)
7、 Show /var/log/secure The file contains “Failed” or “FAILED” The line of ;
[[email protected] test]# egrep "(Failed|FAILED)" /var/log/secure
8、 stay /etc/passwd Take out the default shell by bash The line of ;
[[email protected] test]# grep "bash" /etc/passwd root:x:0:0:root:/root:/bin/bash redhat:x:1000:1000:redhat:/home/redhat:/bin/bash tom:x:1003:1003::/home/tom:/bin/bash user1:x:1004:1004::/home/user1:/bin/bash user2:x:1005:1005::/home/user2:/bin/bash user3:x:1006:1006::/home/user3:/bin/bash user4:x:1007:1007::/home/user4:/bin/bash user5:x:1008:1008::/home/user5:/bin/bash user6:x:1009:1009::/home/user6:/bin/bash user7:x:1010:1010::/home/user7:/bin/bash user8:x:1011:1011::/home/user8:/bin/bash user9:x:1012:1012::/home/user9:/bin/bash user10:x:1013:1013::/home/user10:/bin/bash user11:x:1014:1014::/home/user11:/bin/bash user12:x:1015:1015::/home/user12:/bin/bash user13:x:1016:1016::/home/user13:/bin/bash user14:x:1017:1017::/home/user14:/bin/bash user15:x:1018:1018::/home/user15:/bin/bash user16:x:1019:1019::/home/user16:/bin/bash user17:x:1020:1020::/home/user17:/bin/bash user18:x:1021:1021::/home/user18:/bin/bash user19:x:1022:1022::/home/user19:/bin/bash user20:x:1023:1023::/home/user20:/bin/bash
9、 List... In long format /etc/ Directory to ns start 、.conf File information at the end ;
[[email protected] test]# ll /etc/ns*.conf lrwxrwxrwx. 1 root root 29 Jul 9 12:47 /etc/nsswitch.conf -> /etc/authselect/nsswitch.conf
10、 Highlight passwd Colon in file , And the characters on both sides ;
[[email protected] test]# grep -E --color "(.(:.){1,}|.:+.)" /etc/passwd
1、 Delete /etc/grub2.conf All the white space characters at the beginning of the line that start with white space in the file
[[email protected] etc]# vim testgrub.conf jdskjgfkllksllkldkjfl kjkdjjlas dksjkdjksjl fjkjdsjf kdjfjdskla jdksjfkjksjlkf kfdsjlflmmflmdl dsjfjlsaksakkfldkkdkl [[email protected] etc]# sed -r 's/^[[:space:]]//' /etc/testgrub.conf jdskjgfkllksllkldkjfl kjkdjjlas dksjkdjksjl fjkjdsjf kdjfjdskla jdksjfkjksjlkf kfdsjlflmmflmdl dsjfjlsaksakkfldkkdkl
2、 Delete /etc/fstab All # start , The first line of a line followed by at least one white space character # And white space characters
[[email protected] rc.d]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat Jul 9 04:36:11 2022 # # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # /dev/mapper/rhel-root / xfs defaults 0 0 UUID=8e1cec7b-3876-430c-a34c-8c6c658ce96a /boot xfs defaults 0 0 /dev/mapper/rhel-swap none swap defaults 0 0 /dev/sr0 /mnt iso9660 defaults 0 0 [[email protected] test]# sed -r 's/^#[[:space:]]*//' /etc/fstab /etc/fstab Created by anaconda on Sat Jul 9 04:36:11 2022 Accessible filesystems, by reference, are maintained under '/dev/disk/'. See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. After editing this file, run 'systemctl daemon-reload' to update systemd units generated from this file. /dev/mapper/rhel-root / xfs defaults 0 0 UUID=8e1cec7b-3876-430c-a34c-8c6c658ce96a /boot xfs defaults 0 0 /dev/mapper/rhel-swap none swap defaults 0 0 /dev/sr0 /mnt iso9660 defaults 0 0
3、 stay /root/install.log Add... At the beginning of each line # Number
[[email protected] test]# sed -r 's/^.*$/#&/' /root/install.sh
4、 stay /etc/fstab The document does not contain # The beginning of the first line increases # Number
[[email protected]host test]# sed -r 's/^[^\#]/#&/' /etc/fstab # # /etc/fstab # Created by anaconda on Sat Jul 9 04:36:11 2022 # # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # #/dev/mapper/rhel-root / xfs defaults 0 0 #UUID=8e1cec7b-3876-430c-a34c-8c6c658ce96a /boot xfs defaults 0 0 #/dev/mapper/rhel-swap none swap defaults 0 0 #/dev/sr0 /mnt iso9660 defaults 0 0
5、 utilize sed Take out ifconfig In the command IPv4 Address
[[email protected] test]# ifconfig | sed -n 2p | sed -r "s/.*inet[[:space:]]*//" | sed -r "s/[[:space:]]*netmask.*//" 192.168.223.132
6、 Turn off the machine SELinux The function of
[[email protected] test]# sed -I 's#SELINUX=enforced#SELINUX=disabled#g' [[email protected] test]# getenforce Disabled
7、 stay /etc/hosts Add content to the configuration file
[[email protected] test]# sed -i '1 i 1234567' /etc/hosts [[email protected] test]# sed -i '$ a qwertyu' /etc/hosts [[email protected] test]# cat /etc/hosts 1234567 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.223.132 www.ceshi.com qwertyu
边栏推荐
- 机器学习之线性回归(最小二乘法手写+sklearn实现)
- [AAAI] attention based spatiotemporal graph convolution network for traffic flow prediction
- 7.9-7.17 new features and grammar of learning plan ES6
- Use cpolar to publish raspberry pie web pages (improvement of cpolar function)
- [Yunzhu co creation] [hcsd live broadcast] teach the interview tips of big companies in person
- 综合设计一个OPPE主页--页面的底部
- System architect learning
- 分布式Session共享的4类技术方案,与优劣势比较
- 2021年CS保研经历(六):系统填报 + 一些感想
- Div horizontal layout aligned on both sides
猜你喜欢

PyQt5快速开发与实战 6.1 好软件的三个维度 && 6.2 PyQt5中的布局管理 && 6.3 PyQt5的绝对位置布局

《UnityShader入门精要》总结(2):初级篇

Four types of technical solutions shared by distributed sessions, and their advantages and disadvantages
![[Apple Developer account]06 after transferring the developer account, the annual fee of the developer is automatically renewed](/img/a7/12fd63f16ebca81a3dd2d1b97847d1.png)
[Apple Developer account]06 after transferring the developer account, the annual fee of the developer is automatically renewed

《LOL》从代码上来说最难的是哪个英雄?

How to realize the isolation level between MySQL transactions and mvcc

【微信小程序】接口生成自定义首页二维码
![[C language] minesweeping (recursive expansion + marking function)](/img/f6/835ac4ba6588fa61edb30446f4c708.png)
[C language] minesweeping (recursive expansion + marking function)

Gao Zhiwei: data management enables the digital transformation of the transportation industry

Mysql database final review question bank
随机推荐
那句话的作用
英特尔联合Datawhale,发布学习项目!
网络安全(5)
Detailed explanation: what is the GPS Beidou time service server?
核酸扫码登记体验有感(如何提高OCR的文字正确识别率)
Shutter -- use camera (continuously updating)
Pyqt5 rapid development and practice 6.5 qgridlayout (grid layout)
Mysql database final review question bank
分布式Session共享的4类技术方案,与优劣势比较
[ts]Typescript学习记录坑点合集
RTMP supports h265 streaming
Anfulai embedded weekly report no. 273: 2022.07.04--2022.07.10
On contract testing
Fluent text editor
智慧解决问题
What is Cartland number? What are the applications?
How to realize the isolation level between MySQL transactions and mvcc
Nutnews developed based on arkui ETS
【C语言】扫雷(递归展开 + 标记功能)
Study and exploration of Redux API implementation of Redux