分支字符串是24000ACB
,我如何将其取出sed
?
我试过echo 'origin/releases/2400ACB 294125569b2dc926158b64115f1467f916c9 WIP' | sed 's/[origin/releases/]//g'
。
答案1
origin/releases/
打印以下包含多个非空格字符的部分:
echo 'origin/releases/2400ACB 294125569b2dc926158b64115f1467f916c9 WIP' | sed -n 's/origin\/releases\/\([^ ]\+\).*/\1/p'
或者打印最后一个/
包含多个非空格字符的部分:
echo 'origin/releases/2400ACB 294125569b2dc926158b64115f1467f916c9 WIP' | sed -n 's/.*\/\([^ ]\+\).*/\1/p'
答案2
尝试echo 'origin/releases/2400ACB 294125569b2dc926158b64115f1467f916c9 WIP' | sed 's/[origin/releases/]//g' | awk '{print $1}'