开发者

Encoding an ampersand for twitter w/ curl

开发者 https://www.devze.com 2022-12-16 16:41 出处:网络
Here\'s my code: 开发者_如何学Gocurl -u \"u:d\" --data-urlencode \"status=`echo $@|tr \' \' \'+\'|tr \'&\' \'%26\'`\" \"http://twitter.com/statuses/update.json\"

Here's my code:

开发者_如何学Gocurl -u "u:d" --data-urlencode "status=`echo $@|tr ' ' '+'|tr '&' '%26'`" "http://twitter.com/statuses/update.json"

But when it goes to twitter, the '&' turns into '%'. What am I doing wrong? Thanks!


tr performs individual character replacement.

It replaces & with % because that's what you told it to do.

You want something like sed which does more than just character-by-character substitution.


sed "s/\&/\%26/g"

0

精彩评论

暂无评论...
验证码 换一张
取 消