【发布时间】:2022-10-17 17:54:28
【问题描述】:
我正在尝试基于正则表达式获取第一个匹配组,但在第二个 awk 命令之后它没有打印任何内容。不知道我做错了什么。任何帮助是极大的赞赏。
git status | awk 'NR=1' --> Limiting this t0 print the first line.
On branch TA1692959
git status | awk 'NR=1' | awk '/^On\sbranch\s([\w]*)/{ print $1 }' --> I was trying to get the first word "TA1692959" after "On branch"this prints nothing.
【问题讨论】: