I am using the goo.gl URL shortener to shorten URL's with a curl command. The command is below:
curl https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' \
-d '开发者_运维问答{"longUrl": "http://www.google.com/"}'
This returns the response is below:
{
"kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/"
}
Is there a way to use pbcopy to only copy the shortened URL? (http://goo.gl/fbsS)
I am new to posting on StackOverflow, and would appreciate any responses I can get.Try this:
$ curl ... | grep '"id":' | cut -d\" -f 4 | pbcopy
精彩评论