1、删除/etc/grub2.conf文件中所有以空白开头的行行首的空白字符
sed -r 's/^[[:space:]]//' /etc/grub2.cfg
2、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
sed -r 's/^#[[:space:]]*//' /etc/fstab
3、在/root/install.log每一行行首增加#号
sed -r 's/^.*$/#&/' /root/install.log
4、在/etc/fstab文件中不以#开头的行的行首增加#号
sed -r 's/^[^\#]/#&/' /etc/fstab
5、利用sed 取出ifconfig命令中本机的IPv4地址
ifconfig | sed -n 2p | sed -r "s/.*inet[[:space:]]*//" | sed -r "s/[[:space:]]*netmask.*//"
6、关闭本机SELinux的功能
sed -I 's#SELINUX=enforced#SELINUX=disabled#g'
7、在/etc/hosts配置文件中添加内容
[root@localhost ~]# sed -i '1 i 520' /etc/hosts
[root@localhost ~]# sed -i '$ a 521' /etc/hosts
[root@localhost ~]# cat /etc/hosts
520
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.111.134 localhost
521