简体   繁体   English

ksh IP地址模式

[英]ksh IP address pattern

Trying to match $1 to see if it's an IP address in ksh. 尝试匹配$ 1以查看它是否是ksh中的IP地址。

if [ $1 = "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" ]

doesn't seem to be identifying the following 似乎无法识别以下内容

ksh -x samp.sh 192.168.128.10

Try 尝试

"[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"

Ksh only has a subset of regex . Ksh只有一个regex子集

I used the following regular expression evaluation in KSH93 and it worked for me. 我在KSH93中使用了以下正则表达式评估,并且对我有用。

if [[ $1 == {1,3}(\d).{1,3}(\d).{1,3}(\d).{1,3}(\d) ]]
then
# regex expression evaluated to true
<< perform some action here .... >>
else
# regex expression evaluated to false
<< perform some action here .... >>
fi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM