zoukankan      html  css  js  c++  java
  • shell编程笔记三:流程控制

    格式:
    if ....; then
      ....
    elif ....; then
      ....
    else
      ....
    fi
    

    [ -f "somefile" ] :判断是否是一个文件
    [ -x "/bin/ls" ] :判断/bin/ls是否存在并有可执行权限
    [ -n "$var" ] :判断$var变量是否有值
    [ "$a" = "$b" ] :判断$a和$b是否相等 




    示例:
    #!/bin/bash
    
    if [ ${SHELL} = "/bin/bash" ]; then
       echo "your login shell is the bash (bourne again shell)"
    else
       echo "your login shell is not bash but ${SHELL}"
    fi
    

    判断登陆shell脚本是否为bash


    while循环 if判断 多进程运行 休眠 日期 综合实例
    while true
    do
        nd=`date "+%H%M"`
        if [ "0010" == $nd ] || [ "1507" == $nd ];then
            echo "$nd was found"
            nohup /usr/local/bin/casperjs /syngooglebudget.js 1 >/cas1.txt 2>&1 &
            nohup /usr/local/bin/casperjs /syngooglebudget.js 2 >/cas2.txt 2>&1 &
            sleep 3600s
        else
            sleep 5s
            echo "couln'd foun $nd"
        fi
    done
  • 相关阅读:
    汉诺塔
    美丽联合2018前端
    游览器
    python多线程实现
    cuda toolkit
    编译器,解释器及混合编译
    大疆无人机
    SaaS PaaS IaaS mes
    CNN中权值共享的理解
    最近动作项目心得
  • 原文地址:https://www.cnblogs.com/bjdxy/p/3056853.html
Copyright © 2011-2022 走看看