首页 > 系统服务 > 详细

linux shell 如何约等于字符串

时间:2020-11-05 21:22:25      阅读:45      评论:0      收藏:0      [点我收藏+]
这个以后肯定用的上的,直接放命令了

#!/bin/bash

STR=‘GNU/Linux is an operating system‘
SUB=‘Linux‘

if [[ "$STR" =~ ."$SUB". ]]; then
echo "It‘s there."
fi

答案是 It‘s there

下面这个是我脚本用到的,用正则表达式

            if [ $src_ip = "47.112.15.82" ]
    then
        name="阿里云"
    elif [ $src_ip = "113.16.167.157" ]
    then
        name="清湖中心"
    elif [[ $src_ip =~ .*"180.139".* ]]
    then
        name="梁懿机器"
    else
        name="第三者"
    fi

linux shell 如何约等于字符串

原文:https://blog.51cto.com/12092988/2547176

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!