Unix commands(10)

来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:40 点击:

             /bin/bash
             $SHELL
  最后,还有一种防止这种扩展的方法,那就是使用转义字符——反斜杆:
           echo *.jpg
           echo $SHELL
  这将输出:
           *.jpg
           $SHELL
         6. Here documents
          当要将几行文字传递给一个命令时,here documents(译者注:目前还没有见到过对该词适合的翻译)一种不错的方法。对每个脚本写一段帮助性的文字是很有用的,此时如果我们四有那个 here documents就不必用echo函数一行行输出。 一个 "Here document" 以 << 开头,后面接上一个字符串,这个字符串还必须出现在here document的末尾。下面是一个例子,在该例子中,我们对多个文件进行重命名,并且使用here documents打印帮助:
         #!/bin/sh
         # we have less than 3 arguments. Print the help text:
            if [ $# -lt 3 ] ; then
                 cat <
                 ren -- renames a number of files using sed regular expressions
                 USAGE: ren 'regexp' 'replacement' files...
                 EXAMPLE: rename all *.HTM files in *.html:
              ren 'HTM$' 'html' *.HTM
                 HELP
              exit 0
            fi
            OLD="$1"
            NEW="$2"
          # The shift command removes one argument from the list of
          # command line arguments.
          shift
          shift
          # $* contains now all the files:
         for file in $*; do
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • /etc/fstab 详解
  • nginx主主集群
  •  LVS-NAT和LVS-DR模式的实现详解
  •  RHCE考试之磁盘配额
  • 学习笔记:ACL详解
  • suse linux双网卡双网关配置
  •  LVM逻辑卷管理器
  •  Nginx主主负载均衡架构
  • ubuntu学习Mysql

快速直达

操作系统导航

LinuxWindows虚拟机
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1