bash - $str == *"somestring"* 与使用正则表达式
问题描述
我目前正在运行以下 bash 脚本。但是,我不确定这种方法是否完全是一种好方法。我正在尝试test
在以下目录路径中查找子字符串。最好的方法是什么?正则表达式?使用以下示例寻找一些指导
for str in "/directory/manifest" "directory/test/configs" "directory/test/secrets" "directory/main" "directory/bin"; do
if [[ $str == *"test"* ]];then
echo $str
fi
done
解决方案
推荐阅读
- jupyter-notebook - 如何将 Jupyterhub 登录与生成的笔记本连接?
- java - 如何在可观察线程结束之前停止应用程序?
- python - 为河内塔生成一个元组
- reactjs - 禁止发布方法(未设置 CSRF cookie。)
- excel - Excel for macOS - 从 VBA 访问 ComboBox
- tailwind-css - 有没有办法让链接在默认情况下带有下划线?
- wordpress - 如何为 WordPress 中的所有 cookie 添加 sameSite=None 属性标头?
- javascript - 如何将多个值添加到本地存储中的键
- javascript - 格式化日期时不考虑时间的时刻本地化?
- php - 当正则表达式测试似乎工作时,预匹配为空