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.

    可以排查错误

  • 相关阅读:
    斐波那契数列的递归和非递归实现
    二叉树遍历
    基础总结
    内部类
    I/O dempo
    读取文件注意事项
    eclipse 主题设置
    String 常用函数
    多态的理解
    ffmpeg处理RTMP流媒体的命令大全
  • 原文地址:https://www.cnblogs.com/wangshaojun/p/5093200.html
Copyright © 2011-2022 走看看