Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我在变量中有一个文件名。
FILENAME_VAR = "1000-Feature.mp4"
我可以用来测试变量中的文件名是否$FILENAME_VAR包含单词的 bash 命令是什么Feature?
$FILENAME_VAR
Feature
一种方法
if [[ $FILENAME_VAR =~ Feature ]] then echo good else echo bad fi
$ [[ $FILENAME_VAR = *Feature* ]] ; echo $? 0 $ [[ $FILENAME_VAR = *Feature2* ]] ; echo $? 1