[root@localhost ~]#ifconfig ens32 | sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
192.168.37.207
4 删除/etc/fstab文件中所有以#开头,后面至少跟一个空白符的行的行首的#和空白字符。
[root@localhost ~]#sed -nr 's/^#[[:space:]]+(.*)/\1/p' /etc/fstab
/etc/fstab
Created by anaconda on Sun May 3 03:21:04 2020
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
5 处理/etc/fstab路径,使用sed命令取出其目录名和基名。
[root@localhost ~]#echo /etc/fstab | sed -nr 's#(.*)/.*$#\1#p'
/etc
[root@localhost ~]#echo /etc/fstab | sed -nr 's#.*/([^/]+)/?$#\1#p'
fstab