1、查找/etc目录下大于1M且类型为普通文件的所有文件
[root@localhost wudi]#find /etc/ -size +1M -type f -ls
2、打包/etc/目录下面所有conf结尾的文件,压缩包名称为当天的时间,并拷贝到/usr/local/src目录备份。
[root@localhost wudi]#find /etc/ -name .conf | xargs tar -zcpvf date +%F
.tgz && cp date +%F
.tgz /usr/local/src/
使用tar -tf /usr/local/src/2020-05-15.tgz |wc -l 预览打包文件并使用wc命令查看行数与原来打包前做对比
3、利用sed 取出ifconfig命令中本机的IPv4地址
[wudi@192 ~]$ ifconfig | sed -n 2p | sed -nr 's/[0-9]+([0-9.]+) .$/\1/p
4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@localhost ~]# sed -nr ‘s/^#[[:space:]]+(.*)$/\1/p’ /Data/fstab.bak
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@localhost ~]# echo /etc/fstab/ | sed -r ‘s@(/.*/)([/]+)KaTeX parse error: Undefined control sequence: \1 at position 2: @\̲1̲@' /etc/ [root@…@\2@’
fstab