第五週做業

一、查找/etc目錄下大於1M且類型爲普通文件的全部文件linux

[18:13:53 root@centos7_6 ~]# find /etc -type f -size +1M 
/etc/udev/hwdb.bin
/etc/selinux/targeted/active/policy.kern
/etc/selinux/targeted/contexts/files/file_contexts.bin
/etc/selinux/targeted/policy/policy.31
/etc/brltty/zh-tw.ctb

二、打包/etc/目錄下面全部conf結尾的文件,壓縮包名稱爲當天的時間,並拷貝到/usr/local/src目錄備份。
find /etc -name "*.conf" |xargs tar -zcfdate +%F.tar && cp -adate +%F.tar /usr/local/srccentos

三、利用sed 取出ifconfig命令中本機的IPv4地址ide

[22:02:28 root@centos7_6 ~]# ifconfig eth0 |sed -nr '2s/(^[^0-9]+)([0-9.]+)(.*$)/\2/p'   
192.168.151.178

四、刪除/etc/fstab文件中全部以#開頭,後面至少跟一個空白字符的行的行首的#和空白字符centos7

sed -ri.bak 's/(^#[[:blank:]]+)(.*)/\2/' /etc/fstabcode

五、處理/etc/fstab路徑,使用sed命令取出其目錄名和基名get

[00:36:58 root@centos7_6 ~]# echo /etc/fstab |sed -nr 's#(^/.*/)(.*)#\1#p'
/etc/
[00:38:47 root@centos7_6 ~]# echo /etc/fstab |sed -nr 's#(^/.*/)(.*)#\2#p'
fstab
[00:38:50 root@centos7_6 ~]# 
相關文章
相關標籤/搜索