zoukankan      html  css  js  c++  java
  • 及其简单的shell Script脚本


    #!/bin/bash
    #2017-02-09
    #get pdf file
    PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/app/soft/jdk1.7.0_79/bin:/home/anxin/bin
    export PATH
    echo "this is get pdf file and today is "$(date +%Y%m%d)
    read -p "please input policyNo:" file
    read -p "please input file year:" year
    
    /bin/cp /app/axtmp/pdf/${year}/store/${file}.pdf /app/axtmp/
    /bin/cp /app/axtmp/pdf/${year}/signed/${file}.pdf /app/
    echo "store file is /app/axtmp/ , signed file is /app/"

    自己写的第一个shell script脚本

    1 grep --color=auto -C 10 '15011580080' catalina.out   //在该文件中查找字符串出现的位置并高亮,以及上下10行

     成型脚本

     1 #!/bin/bash
     2 set -x
     3 #2017-06-10
     4 #this shell script is test
     5 PATH=/app/jdk8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/app/maven/bin
     6 export PATH
     7 KEY=$1
     8 FILENAME=/app/test/test.xml
     9 NOWPATH=`pwd`
    10 NOWPATH=${NOWPATH}"/"
    11 grep -H "$KEY" *.xml | cut -d : -f 1 >/app/test/test.xml
    12 for line in `cat $FILENAME`
    13 do
    14    file=${NOWPATH}${line}
    15    cp "$file" /app/test
    16 done 
    17 exit 0

    sh 脚本名   参数 //执行方式

    需要修改文件权限,变成可执行文件

    chmod +x filename

    $1   取参数的值

    大致是:查询当前目录下的所有的包含参数的xml文件,保存到/app/test/test.xml文件中,然后循环读取该文件内容将所有的文件拷贝到/app/test这个目录下。

  • 相关阅读:
    没有可持续集成的日子里
    Apache Avro 与 Thrift 比较
    CruiseControl.NET以及使用
    不靠谱产品经理的特征
    Hadoop 新 MapReduce 框架 Yarn 详解
    Storm On YARN
    iOS开发资源:推送通知相关开源项目--PushSharp、APNS-PHP以及Pyapns等
    Swift REPL入门介绍
    学习Swift,一定不能错过的10大开源项目!
    iOS8 Size Classes的理解与使用
  • 原文地址:https://www.cnblogs.com/nihaofenghao/p/6381122.html
Copyright © 2011-2022 走看看