我们的仓库目录路径=/srv/git/repositories/group_name/subgroup_name/project.git
如果组名在路径名中的repositories 之后以'es-' 开头,我们想执行一个脚本。我试过下面的命令来找到模式
任何人都可以帮我得到输出吗?
示例:
if echo $pwd | grep -q -e "/ * / * /repositories/es-* /* /* " ;
谢谢大家
最佳答案
if echo "$PWD" | grep -q 'repositories/es-'; then
execute_script
fi
或使用 bash :
if grep -q 'repositories/es-' <<< "$PWD"; then
execute_script
fi
或
grep -q 'repositories/es-' <<< "$PWD" && execute_script
关于linux - 如果路径中存在模式,则执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49244473/