rya*_*342 2 bash shell-script github
https://github.com/org/repo/pull/777
我试图解析 bash 函数 1 中该 url 的最后一个数字,并将该结果传递给 bash 函数 2。
我有一个我一直在玩的基本例子:
1 pullpr() {
2 git checkout pr/$1
3 }
4
5 co() {
6 pullpr awk -F/ '{print $7}' <<<$1
7 }
Run Code Online (Sandbox Code Playgroud)
我似乎无法让它发挥作用,但我想以正确的方式做到这一点。
您可以使用 shell\xe2\x80\x99s参数扩展功能来提取数字:
\n\nurl=https://github.com/org/repo/pull/777\necho "${url##*/}"\nRun Code Online (Sandbox Code Playgroud)\n\n这也适用于位置参数:
\n\nset https://github.com/org/repo/pull/777\necho "${1##*/}"\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
654 次 |
| 最近记录: |