shell

shell

使用说明:

cat /opt/ailinkoss/zabbix/etc/zabbix_server.conf | grep -Ev "^$|#"

-eq //equals等于
-ne //no equals不等于
-gt //greater than 大于
-lt //less than小于
-ge //greater equals大于等于
-le //less equals小于等于
注:

1、在shell中进行比较时,结果为0代表真,为1代表假。

2、-eq,-ne等比较符只能用于数字比较,有字符也会先转换成数字然后进行比较。

判断字符串为空[ -z "$str" ]; 非空 [ -n "$str" ]

#!/bin/sh
###
### hello to use the shell
###
### Usage:
###    sh fmq-entrypoint.sh FMQ_ID=XXX
###
### Options:
###   XXX       Call the number 13522032872
###   -h        Show this message.

help() {
	awk -F'### ' '/^###/ { print $2 }' "$0"
}

config_path=/opt/proda/fmq/config/clientservice.cfg
fmq_id=`grep -E "^localunitid =" $config_path | awk -F '= ' '{ print $2 }'`
if [ ! -f "$config_path" ] || [[ $fmq_id == "XXX" ]]; then
#    echo "**** Configuration file '$config_path' does not exist"
    help
    exit 1
fi

#if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
#    help
#    exit 1
#fi
posted @ 2024-09-12 16:00  NoYoWiFi  阅读(8)  评论(0)    收藏  举报