小编use*_*865的帖子

使用 Bourne Shell (sh) 在句子中查找单词

我正在尝试使用 Bourne Shell (sh) 确定某个特定单词是否出现在句子中。例如:

#!/bin/bash
INPUT='Lorem ipsum dolor sit amet.'

if [[ "$INPUT" == *dolor* ]]
then
    echo "So true"
else
    echo "Not true"
fi
Run Code Online (Sandbox Code Playgroud)

这适用于bash,但我不能使用bash,我需要一些适用于sh

shell string shell-script regular-expression

4
推荐指数
1
解决办法
1433
查看次数

标签 统计

regular-expression ×1

shell ×1

shell-script ×1

string ×1