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
下一篇 2016-08-12

相关推荐

  • linux基础命令1

    内容包含:文件管理、重定向和管道、用户组和权限管理、文本处理工具

    Linux干货 2017-11-19
  • linux文本处理三剑客-sed

    sed 是什么? sed是一种流编辑器,它是文本处理中非常中的工具,在linux中被称为linux文本处理三剑客之一,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文…

    Linux干货 2017-03-15
  • Linux终端类型

    在linux系统中,用户经常要使用各种终端和操作系统进行交互,实现用户的任务。Linux各种终端的工作方式基本都通过字符命令行的方式完成,通过终端输入命令完成相应结果。通过who命令可查看用户通过哪些终端方式连接到操作系统。通过tty命令查看当前是通过第几个tty登录的。 Linux系统的终端包含如下几种类型: 1) 物理终端 物理终端,又称控制台…

    Linux干货 2016-10-17
  • DNS and BIND 初步

    DNS and bind 初步 前言 TCP/IP协议通信是针对于ip地址的,你说我要是去淘宝买东西,怎么可能记住ip地址,我要是去百度买东西,也记不住啊,所以针对于此,就出现了这样一个翻译器,起一个名字,跟ip地址对应。是多对一还是一对多呢,都可以,我几个ip指向一个网址也没问题,几个网址指向一个ip也可以。 对于反向域名解析功能等以后用到再做总结,反向域…

    Linux干货 2016-12-06
  • linux 进程及作业管理

     1、Process: 运行中的程序的一个副本,是被载入内存的一个指令集合 进程ID(Process ID,PID)号码被用来标记各个进程 UID、GID、和SELinux语境决定对文件系统的存取和访问权限, 通常从执行进程的用户来继承 存在生命周期 Uninterruptible sleep: 不可中断的睡眠 Interruptible slee…

    Linux干货 2017-08-28
  • 通配符、正则表达式小计

    基本通配符:    *: 匹配任意长度的任意字符;    ?: 匹配任意的单个字符;    []: 匹配指定范围内的任意单个字符;    [^]: 匹配非指定范围内的任意单个字符;   简单示例:   &nbs…

    Linux干货 2017-03-16