vim编辑器作业

1、复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符
[root@wzc tmp]# vim profile 
 
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"  
else        
. "$i" >/dev/null
fi          
fi              
done        
    
unset i
unset -f pathmunge
###:%s/^[[:space:]]\+//g  命令
2、复制/etc/rc.d/init.d/functions文件至/tmp目录,用查找替换命令为/tmp/functions的每行开头为空白字符的行的行首添加一个
#           
#           
#       
#       
#   
}
# A sed expression to filter out the files that is_ignored_file recognizes
__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
if [ "$_use_systemctl" = "1" ]; then
#       
#               
#               
#               
#               
#               
#               
#               
#               
#       
fi
####:%s/^[[:space:]]\+.*/#/g  命令
3、如何设置tab缩进为4个字符?
160            shift 2
161            ;;  
162         --check=?*)
163                base=${1#--check=}
164            gotbase="yes"
165            shift
166            ;;  
167         --user)
168            user=$2
169            shift 2
170            ;;  
171         --user=?*)
172                user=${1#--user=}
173            shift
174            ;;  
175         --pidfile)
176            pid_file=$2
177            shift 2
178            ;;  
179         --pidfile=?*)
180            pid_file=${1#--pidfile=}
181            shift
182            ;;  
###:set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab nu autoindent cindent  命令
4、复制/etc/rc.d/init.d/functions文件至/tmp目录;替换/tmp/functions文件中的/etc/sysconfig/init为/var/log;
# Read in our configuration
if [ -z "${BOOTUP:-}" ]; then
  if [ -f /var/log ]; then
      . /var/log
  else
    # This all seem confusing? Look in /var/log,
    # or in /usr/share/doc/initscripts-*/sysconfig.txt
    BOOTUP=color
    RES_COL=60
    MOVE_TO_COL="echo -en \\033[${RES_COL}G"
    SETCOLOR_SUCCESS="echo -en \\033[1;32m"
    SETCOLOR_FAILURE="echo -en \\033[1;31m"
    SETCOLOR_WARNING="echo -en \\033[1;33m"
    SETCOLOR_NORMAL="echo -en \\033[0;39m"
    LOGLEVEL=1
  fi
  if [ "$CONSOLETYPE" = "serial" ]; then
      BOOTUP=serial
###:%s@/etc/sysconfig/init@/var/log@gi  命令
5、删除/tmp/functions文件中所有以#开头,且#后面至少有一个空白字符的行的行首的#号;
A sed expression to filter out the files that is_ignored_file recognizes
__sed_discard_ignored_files='/\(~\|\.bak\|\.orig\|\.rpmnew\|\.rpmorig\|\.rpmsave\)$/d'
  
if [ "$_use_systemctl" = "1" ]; then
        if  [ "x$1" = xstart -o \
                "x$1" = xstop -o \
                "x$1" = xrestart -o \
                "x$1" = xreload -o \
                "x$1" = xtry-restart -o \
                "x$1" = xforce-reload -o \
                "x$1" = xcondrestart ] ; then
        
###:%s@^#[[:space:]]\{1,\}@@  命令

原创文章,作者:RecallWzc,如若转载,请注明出处:http://www.178linux.com/33338

(0)
RecallWzcRecallWzc
上一篇 2016-08-12 09:01
下一篇 2016-08-12 09:01

相关推荐

  • Linux破解root口令

    Centos5、6版本破解口令方法 1 启动系统 2 在操作系统选择菜单界面选中要启动的内核 — 按a键 3 在行尾输入 1(或s或S或single)— 按回车键 4 使用passwd命令修改口令即可   Centos7版本破解口令方法 方法1 1 启动系统 2 在操作系统选择菜单界面选中要启动的内核 — 按e键…

    Linux干货 2018-01-08
  • shell脚本编程基础(1)

    一.位置变量相关知识     1.位置变量定义:在脚本代码中调用通过命令行传递给脚本的的参数     2.位置变量种类:              &…

    Linux干货 2016-08-15
  • rsyslog讲解

    rsyslog: 日志:历史日志 syslog(服务):syslogd(系统日志)、klogd(内核日志) c/s架构;服务,可监听于某套接字,帮其他主机记录日志信息 日志格式 /etc/rsyslog.conf facitlity.priority         &…

    Linux干货 2016-10-28
  • Homework Week-6 vim使用、脚本编程

    请详细总结vim编辑器的使用并完成以下练习题 1、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; cp /etc/rc.d/rc.sysinit /tmp/ vim /tmp/rc.sysinit 转换为末行模式: :%s@^[[:s…

    Linux干货 2016-09-19
  • ./././

    ./././

    Linux干货 2016-08-04
  • 8.3-特殊权限(作业篇)

    1. 在/data/testdir里创建的新文件自动属于g1组,组g2的成员如: alice能对这些新文件有读写权限,组g3的成员如: tom只能对新文件有读权限,其它用户(不属于,g2,g3)不能访问这个文件夹。 root@localhost ~]# mkdir -p /data/testdir [root…

    Linux干货 2016-08-04