20160808作业
1、每日课堂笔记总结
2、预习
3、每日课堂pdf练习
1、删除/etc/grub2.cfg文件中所有以空白开头的行行首的空白字符
[root@Centos7 ~]# sed '/^[[:space:]]\+/d' /etc/grub2.cfg # # DO NOT EDIT THIS FILE # # It is automatically generated by grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### set pager=1 if [ -s $prefix/grubenv ]; then fi if [ "${next_entry}" ] ; then else fi if [ x"${feature_menuentry_id}" = xy ]; then else fi export menuentry_id_option if [ "${prev_saved_entry}" ]; then fi function savedefault { } function load_video { } terminal_output console if [ x$feature_timeout_style = xy ] ; then # Fallback normal timeout code in case the timeout_style feature is # unavailable. else fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/00_tuned ### set tuned_params="" ### END /etc/grub.d/00_tuned ### ### BEGIN /etc/grub.d/01_users ### if [ -f ${prefix}/user.cfg ]; then fi ### END /etc/grub.d/01_users ### ### BEGIN /etc/grub.d/10_linux ### menuentry 'CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-4b461f3a-1b13-49c9-80eb-0a03f4fa9519' { } menuentry 'CentOS Linux (0-rescue-d84e4562ec594069be53afee569c711e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-d84e4562ec594069be53afee569c711e-advanced-4b461f3a-1b13-49c9-80eb-0a03f4fa9519' { } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_ppc_terminfo ### ### END /etc/grub.d/20_ppc_terminfo ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f ${config_directory}/custom.cfg ]; then elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then fi ### END /etc/grub.d/41_custom ###
2、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
[root@Centos7 ~]# sed '/^#.*[[:space:]]\+/d' /etc/fstab # # # UUID=4b461f3a-1b13-49c9-80eb-0a03f4fa9519 / xfs defaults 0 0 UUID=c332bc3c-01b4-40e3-b600-c5791719e14b /boot xfs defaults 0 0 UUID=7561a152-2688-4437-a001-814a4cddd745 /testdir xfs defaults 0 0 UUID=bb4c502d-ec7c-4237-811c-30de82daaf68 swap swap defaults 0 0 [root@Centos7 ~]# sed '/^#.*[[:space:]]\+/d' /etc/fstab > f1 [root@Centos7 ~]# diff f1 /etc/fstab 2a3,4 > # /etc/fstab > # Created by anaconda on Thu Jul 21 11:21:52 2016 3a6,7 > # 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
3、在f2每一行行首增加#号
[root@Centos7 ~]# sed -r 's/(^.*)/#&/' f2 #21e@3232.com #maeefe@madede.com #edweww@ddsds.comdw.dewew@dsdwddw.com #1111@111.1111.1111@11111.!111 # #
4、在/etc/fstab文件中不以#开头的行的行首增加#号
[root@Centos7 ~]# sed 's/^[^#].*/#&/' /etc/fstab # # /etc/fstab # Created by anaconda on Thu Jul 21 11:21:52 2016 # # 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 # #UUID=4b461f3a-1b13-49c9-80eb-0a03f4fa9519 / xfs defaults 0 0 #UUID=c332bc3c-01b4-40e3-b600-c5791719e14b /boot xfs defaults 0 0 #UUID=7561a152-2688-4437-a001-814a4cddd745 /testdir xfs defaults 0 0 #UUID=bb4c502d-ec7c-4237-811c-30de82daaf68 swap swap defaults 0 0
5、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@Centos7 ~]# echo "/etc/fstab" |sed -r 's@(.*/)(.*/?)@\1@' /etc/ [root@Centos7 ~]# echo "/etc/fstab" |sed -r 's@(.*/)(.*/?)@\2@' fstab
6、利用sed 取出ifconfig命令中本机的IPv4地址
[root@Centos7 ~]# ifconfig|sed -n '2p'|sed -r 's/.*net (.*) netmask.*/\1/' 10.1.252.77
7、统计centos安装光盘中Package目录下的所有rpm文件的以.分隔倒数第二个字段的重复次数
4、如何设置tab缩进为4个字符?
vim ~/.vimrc set ts=4
5、复制/etc/rc.d/init.d/functions文件至/tmp目录;替换/tmp/functions文件中的/etc/sysconfig/init为/var/log;
扩展命令模式:%s/\/etc/sysconfig\/init\//var\/log/g
[root@Centos7 ~]# sed -n 's/\/etc\/sysconfig\/init/\/var\/log/pg' /tmp/functions if [ -f /var/log ]; then . /var/log # This all seem confusing? Look in /var/log,
6、删除/tmp/functions文件中所有以#开头,且#后面至少有一个空白字符的行的行首的#号;
sed -r 's/^#.*[[:space:]]+.*/[^#].*/' /tmp/functions
原创文章,作者:麦德良,如若转载,请注明出处:http://www.178linux.com/32000