命令替换

2019-07-09  本文已影响0人  平平淡淡的真
根据系统时间计算今年或明年
echo "This is $(date +%Y) year"
echo "This is $(($(date +%Y) + 1))"
判断nginx进程是否存在,如果不存在重新拉起进程

#!/bin/bash
#
nginx_process_num=$(ps -ef | grep nginx | grep -v nginx | wc -l)
if [$nginx_process_num -eq 0 ];then
    systemctl start nginx 
fi

总结: `` 和 ()是等价的,推荐使用(), $(())主要用来进行整数运算

上一篇 下一篇

猜你喜欢

热点阅读