20160808作业

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

(0)
麦德良麦德良
上一篇 2016-08-15
下一篇 2016-08-15

相关推荐

  • Linux的发展史

    前言: Linux是什么?    我们知道Linux这玩意儿是在计算机上面运作的,所以说Linux就是一组软件。问题是这个软件是操作系统还是应用程序? 且Linux可以在哪些种类的计算机上面运作?而Linux源自哪里?为什么Linux 还不用钱?这些我们都得来谈一谈先!      计算机系…

    Linux干货 2016-10-13
  • RAID各级别的特性及使用介绍(8.3博客作业)

    RAID各级别的特性及使用介绍 介绍: 独立硬盘冗余阵列(RAID:Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列,简称磁盘阵列。 组成: 多块磁盘,RAID控制器(硬件RAID、软件RAID)     硬件RAID:自带CPU的RAID卡,不消耗服务器资源,可通过备份…

    Linux干货 2016-07-16
  • linux部署lamp,samba,nfs

    linux部署lamp,samba,nfs 实验拓扑图 实验要求 五台机器使用linux模拟 一台机器做数据库服务器,samba共享服务器,nfs共享服务器 其中两台做http服务器 一台做PC机 实验目的 samba服务器向一台http服务器提供共享服务,做http的DocumentRoot,nfs服务器一样作为另一台http服务器的DocumentRoo…

    2017-05-02
  • 第八周作业

    shell脚本简用

    Linux干货 2017-11-27
  • 马哥教育网络班21期+第八周课程练习

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 网桥:也叫做桥接器,工作在OSI七层中第二层数据链路层,主要是用来连接两个局域网的一种存储或者转发设备,它能将一个大的LAN分隔      为多个网段,也可以将多个LAN互联为一个逻辑LAN,网桥是在数据层上实现的局域网互联;即使…

    Linux干货 2016-09-08
  • Nginx反向代理原理、压测及模块功能的实现

    基本架设 反向代理模块 缓存功能的实现 修改报文首部IP 向后端转发时是否让客户端知道 在http中定义缓存基本属性 定义当后端服务宕机时过期缓存生效条件 报文首部模块,自定义报文首部 负载均衡模块1 负载均衡模块2 负载均衡模块的常用调度方法1 负载均衡常用调度方法2 与http想等的动态负载均衡模块1 与http想等的动态负载均衡模块2 这里让我们对之前…

    2016-10-30