美文网首页
第五周作业

第五周作业

作者: 别把风景搬上天堂 | 来源:发表于2019-12-29 22:19 被阅读0次

1、查找/etc目录下大于1M且类型为普通文件的所有文件

[root@localhost data]# find /etc/ -size +1M -type f
/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
# xargs 接受标准输入并处理为相应命令的参数
[root@localhost data]# find /etc/ -size +1M -a -type f | xargs ls -lh
-rw-r--r--. 1 root root 1.4M Apr 11  2018 /etc/brltty/zh-tw.ctb
-rw-------. 1 root root 3.8M Nov  3  2018 /etc/selinux/targeted/active/policy.kern
-rw-r--r--. 1 root root 1.4M Nov  3  2018 /etc/selinux/targeted/contexts/files/file_contexts.bin
-rw-r--r--. 1 root root 3.8M Nov  3  2018 /etc/selinux/targeted/policy/policy.31
-r--r--r--. 1 root root 7.8M Nov 25 22:19 /etc/udev/hwdb.bin

2、打包/etc/目录下面所有conf结尾的文件,压缩包名称为当天的时间,并拷贝到/usr/local/src目录备份。

[root@localhost /]# tar zcvPf /usr/local/src/`date +"%F-%T"`.tar.gz /etc/*.conf
/etc/asound.conf
/etc/autofs.conf
/etc/autofs_ldap_auth.conf
#  tar默认为相对路径,使用绝对路径的话就会报这个错tar: Removing leading `/' from member names    使用-P参数解决。
......省略以下内容
[root@localhost /]# ll /usr/local/src/
-rw-r--r--. 1 root root 49732 Dec 28 22:53 2019-12-28-22:53:28.tar.gz
-rw-r--r--. 1 root root 49727 Dec 28 22:53 2019-12-28-22:53:49.tar.gz

3、利用sed 取出ifconfig命令中本机的IPv4地址

[root@localhost ~]# ifconfig ens32|sed -n '2p' |sed 's/.*inet //' |sed 's/ netmask.*//'
192.168.27.134
[root@localhost ~]# ifconfig ens32| sed -r '2!d;s@(.*inet )(.*)( net.*)@\2@'
192.168.27.134 

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

[root@localhost ~]# sed -i 's/^#|^#[[:space:]]\+//g' /etc/fstab

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@localhost ~]# echo "/etc/fstab"|sed -r 's@(.*)\/.+@\1@'
/etc
[root@localhost ~]# echo "/etc/fstab"|sed -r 's@.*\/(.+)@\1@'
fstab

相关文章

  • 正念冥想--知行家11.0精力管理.2践行之五

    212班11.0践行第五周作业安排(2021.9.18~9.24) 第五周主题:正念冥想 作业:1.结合平时的学习...

  • 20210919冥想作业

    群公告 212班11.0践行第五周作业安排(2021.9.18~9.24) 第五周主题:正念冥想 作业:1.结合平...

  • 2018-08-04

    王若松第五周词语作业

  • 135

    20170930,第五周周六。 国庆数学作业。 国庆节物理作业。 本周物理测...

  • 第五周假期生活

    时间过得真快,已经是假期的第五周啦。第五周里我完成的作业是。数学作业完成啦!数学暑假作业也完成啦。语文...

  • 129

    20170925,第五周周一。 语文周末作业完成情况。 数学周考情况 英语...

  • 效能复盘践行(五)掌握未来两周的固定日程--五色周表的运用

    212班10.0践行第五周作业安排(2020.5.29~6.4) 第五周主题:掌握未来两周的固定日程--五色周表的...

  • 假期第五周

    这个第五周呀,我干了很多事情,练字、弹古筝、洗碗、游泳、数学作业、听写、还有我的第五周总结...

  • 2020-02-09

    《自私的基因》第五周 2.3—2.9 精读 第五、六、七章 作业提交格式: 读书总结《_____________...

  • 人生200事

    59班3.0-1组-01号 第五周作业

网友评论

      本文标题:第五周作业

      本文链接:https://www.haomeiwen.com/subject/sujeoctx.html