相关疑难解决方法(0)

如何使用/ bin/sh检查模式匹配,而不是/ bin/bash

我正在使用Ubuntu系统shell,而不是bash,我发现常规方式无法正常工作:

#!/bin/sh
string='My string';

if [[ $string =~ .*My.* ]]
then
   echo "It's there!"
fi
Run Code Online (Sandbox Code Playgroud)

错误[[:找不到!

我该怎么做才能解决这个问题?

shell

16
推荐指数
3
解决办法
2万
查看次数

标签 统计

shell ×1