Is there an existing issue for the feature request?
Feature Description
check/ck_hostname: check if current host name matches given regular expression
usage:
check/ck_hostname.sh <reg_expr>, where,
reg_expr: a regular expression, e.g. "^abc.*$"
example:
check/ck_hostname.sh "^abc.*$"
github@test0:/data/cus_reg$ /tmp/1.sh "^test.*$"
The hostname test0 matches the regex pattern.
github@test0:/data/cus_reg$ /tmp/1.sh "^tes.*$"
The hostname test0 matches the regex pattern.
github@test0:/data/cus_reg$ /tmp/1.sh "^tes1.*$"
The hostname test0 does not match the regex pattern.
output:
return 0: if matches
return 1: otherwise
Feature Implementation
hostname=`hostname`
reg_exp="$1"
if [[ ${hostname} =~ "${reg_exp}" ]]; then
echo "matches"
fi
Additional information
No response