zoukankan      html  css  js  c++  java
  • Shell编程进阶 1.2 shell结构及执行

    创建一个shell脚本

    mkdir shell
    vim first.sh
    #!/bin/bash
    ##The first test shell script.
    ##Written by wangshaojun.
    
    ls /tmp/
    echo "my home is $HOME"
    echo "This is first script"

    执行shell脚本,两种方法

    bash first.sh

    mysql.sock www_slow.log
    2015-12-31.wangshaojun.root.history-timestamp pear www.sock
    2016-01-01.wangshaojun.root.history-timestamp www1.sock
    my home is /root
    This is first script.

    或者 

    sh first.sh

    第二种方法

    chmod a+x first.sh
    ./first.sh

    绝对路径

    /root/shell/first.sh

    脚本的执行过程

    sh -x first.sh

    + ls /tmp
    12334 mysql.sock www_slow.log
    2015-12-31.wangshaojun.root.history-timestamp pear www.sock
    2016-01-01.wangshaojun.root.history-timestamp www1.sock
    + echo 'my home is /root'
    my home is /root
    + echo 'This is first script.'
    This is first script.

    可以排查错误

  • 相关阅读:
    Springmvc
    Mybatis关联关系
    Mybatis整合ehcache 和 redis
    Mybatis与spring集成
    MyBatis动态sql和分页
    MyBatis入门
    Vue模板语法(二)
    Vue模板语法(一)
    Spring---SSH整合(二)
    Spring---SSH整合
  • 原文地址:https://www.cnblogs.com/wangshaojun/p/5093200.html
Copyright © 2011-2022 走看看