【问题标题】:pbcopy Specific Part of Shell Scriptpbcopy Shell 脚本的特定部分
【发布时间】:2011-09-01 00:27:35
【问题描述】:

我正在使用 goo.gl URL 缩短器通过 curl 命令缩短 URL。命令如下:

curl https://www.googleapis.com/urlshortener/v1/url \
  -H 'Content-Type: application/json' \
  -d '{"longUrl": "http://www.google.com/"}'

返回的响应如下:

{
 "kind": "urlshortener#url",
 "id": "http://goo.gl/fbsS",
 "longUrl": "http://www.google.com/"
}

有没有办法使用 pbcopy 只复制缩短的 URL? (http://goo.gl/fbsS)
我是在 StackOverflow 上发帖的新手,如果我能得到任何回复,我将不胜感激。

【问题讨论】:

    标签: shell terminal goo.gl pbcopy


    【解决方案1】:

    试试这个:

    $ curl ... | grep '"id":' | cut -d\" -f 4 | pbcopy
    

    【讨论】:

    • 谢谢你的回答,我以前见过这种命令,但我不确定如何在脚本中实现它。我猜我等待响应,然后运行?: grep '"id":' |剪切 -d\" -f 4 | pbcopy
    猜你喜欢
    • 2013-12-08
    • 1970-01-01
    • 1970-01-01
    • 2017-06-28
    • 2013-10-26
    • 1970-01-01
    • 2021-05-15
    • 2021-11-29
    相关资源
    最近更新 更多