Skip to content

[Feature Request]: check/ck_hostname: check if current host name matches given regular expression #80

@aronchanisme

Description

@aronchanisme

Is there an existing issue for the feature request?

  • I have checked the existing issues.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions