挺不错的额~学习了~ 在 2012年5月12日 下午4:44,Hex Lee <lihe...@gmail.com> 写道: > Mac版本,因为unix 和 linux的sed命令有差异,注意换行符号的处理: > # Mac Version > # notic: ^M^L = Ctrl+v Ctrl+Enter Ctrl+v Ctrl+l > ts(){ > result=`curl -s \ > "http://dict.cn/ws.php?utf8=true&q=$1" `; > > echo $result | sed -E -n 's/.*<def>([^<]+)<\/def>.*/\1/p'; > > #examples > echo $result \ > | sed -E -n 's/.*def> (<sent><orig>.*<\/sent>).*/\1/p' \ > | sed 's/<em>//g' \ > | sed 's/<\/em>//g' \ > | sed 's/<trans>/^M^L/g' \ > | sed 's/<orig>/^M^L/g' \ > | sed 's/<[^<>]*>//g' ; > > return 0; > > } > > 在 2012年5月12日 下午4:16,Hex Lee <lihe...@gmail.com>写道: > >> 大家好: >> [image: 内嵌图片 1] >> 我根据chrome 插件halo word dictionary 写了一个新版本的bash脚本与大家分享,另外感谢他们提供的翻译服务 >> 功能: >> 纯粹的字典功能,一次只能查一个单词 >> 特色: >> 更详细,带词性,带例句 >> >> 效果如下: >> $ ts apple >> n.苹果, 珍宝, 家伙 >> >> My uncle has an apple orchard. >> 我叔叔拥有一个苹果园。 >> The apple pie and custard are delicious. >> 苹果饼和软冻的味道好极了。 >> The apple trees are blossoming. >> 苹果树正在开花。 >> >> $ ts driver >> n.驾驶员, 司机, 驱动器 >> >> The driver was not to blame for the accident. >> 这次事故怪不着司机。 >> I'm a hopeless driver, but the examiner let me through. >> 我开车的技术糟透了,但考官让我及格了。 >> The driver was weaving his way through the traffic. >> 司机在车辆和人流中曲折前进。 >> >> bash脚本,使用方法和以前一样加入到~/.bashrc(for linux) : >> >> ts(){ >> result=`curl -s \ >> "http://dict.cn/ws.php?utf8=true&q=$1" `; >> >> echo $result | sed -r -n 's/.*<def>([^<]+)<\/def>.*/\1/p'; >> >> #examples >> echo $result \ >> | sed -r -n 's/.*def> (<sent><orig>.*<\/sent>).*/\1/p' \ >> | sed 's/<em>//g' \ >> | sed 's/<\/em>//g' \ >> | sed 's/<trans>/\n/g' \ >> | sed 's/<orig>/\n/g' \ >> | sed 's/<[^<>]*>//g'; >> >> return 0; >> >> } >> >> >> 2012/4/13 codewalkertse <xyy.xx.vic...@gmail.com> >> >>> 非常好的一个脚本 感谢分享 >>> >>> >>> 在 2012年3月23日星期五UTC+8下午11时26分10秒,Hex Lee写道: >>>> >>>> ts(){ >>>> >>>> curl -s \ >>>> "http://fanyi.youdao.com/**translate?smartresult=dict&** >>>> smartresult=rule&smartresult=**ugc&sessionFrom=dict.top<http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top>" >>>> \ >>>> -d \ >>>> "type=AUTO& i=$1&doctype=json&xmlVersion=**1.4&keyfrom=fanyi.web&ue=UTF- >>>> **8&typoResult=true&flag=false" \ >>>> | sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ; >>>> >>>> return 0; >>>> } >>>> >>>> 设置如下: >>>> linux用户: >>>> 1.添加此脚本到~/.bashrc的末尾 >>>> 2.source ~/.bashrc >>>> Mac osX用户: >>>> >>>> 1.添加此脚本到~/.bash_profile的末尾,**没有就新建 >>>> 2.source ~/.bash_profile >>>> >>>> 使用: >>>> >>>> >>>> Shell代码 >>>> $ ts hello >>>> 你好 >>>> $ ts "how are you?" >>>> 你好吗? >>>> >>>> 也可以翻译中文。 >>>> >>>> 原文地址 <http://hexlee.iteye.com/blog/1442506> >>>> >>> >>> 在 2012年3月23日星期五UTC+8下午11时26分10秒,Hex Lee写道: >>>> >>>> ts(){ >>>> >>>> curl -s \ >>>> "http://fanyi.youdao.com/**translate?smartresult=dict&** >>>> smartresult=rule&smartresult=**ugc&sessionFrom=dict.top<http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top>" >>>> \ >>>> -d \ >>>> "type=AUTO& i=$1&doctype=json&xmlVersion=**1.4&keyfrom=fanyi.web&ue=UTF- >>>> **8&typoResult=true&flag=false" \ >>>> | sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ; >>>> >>>> return 0; >>>> } >>>> >>>> 设置如下: >>>> linux用户: >>>> 1.添加此脚本到~/.bashrc的末尾 >>>> 2.source ~/.bashrc >>>> Mac osX用户: >>>> >>>> 1.添加此脚本到~/.bash_profile的末尾,**没有就新建 >>>> 2.source ~/.bash_profile >>>> >>>> 使用: >>>> >>>> >>>> Shell代码 >>>> $ ts hello >>>> 你好 >>>> $ ts "how are you?" >>>> 你好吗? >>>> >>>> 也可以翻译中文。 >>>> >>>> 原文地址 <http://hexlee.iteye.com/blog/1442506> >>>> >>> >>> 在 2012年3月23日星期五UTC+8下午11时26分10秒,Hex Lee写道: >>>> >>>> ts(){ >>>> >>>> curl -s \ >>>> "http://fanyi.youdao.com/**translate?smartresult=dict&** >>>> smartresult=rule&smartresult=**ugc&sessionFrom=dict.top<http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top>" >>>> \ >>>> -d \ >>>> "type=AUTO& i=$1&doctype=json&xmlVersion=**1.4&keyfrom=fanyi.web&ue=UTF- >>>> **8&typoResult=true&flag=false" \ >>>> | sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ; >>>> >>>> return 0; >>>> } >>>> >>>> 设置如下: >>>> linux用户: >>>> 1.添加此脚本到~/.bashrc的末尾 >>>> 2.source ~/.bashrc >>>> Mac osX用户: >>>> >>>> 1.添加此脚本到~/.bash_profile的末尾,**没有就新建 >>>> 2.source ~/.bash_profile >>>> >>>> 使用: >>>> >>>> >>>> Shell代码 >>>> $ ts hello >>>> 你好 >>>> $ ts "how are you?" >>>> 你好吗? >>>> >>>> 也可以翻译中文。 >>>> >>>> 原文地址 <http://hexlee.iteye.com/blog/1442506> >>>> >>> >>> 在 2012年3月23日星期五UTC+8下午11时26分10秒,Hex Lee写道: >>>> >>>> ts(){ >>>> >>>> curl -s \ >>>> "http://fanyi.youdao.com/**translate?smartresult=dict&** >>>> smartresult=rule&smartresult=**ugc&sessionFrom=dict.top<http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top>" >>>> \ >>>> -d \ >>>> "type=AUTO& i=$1&doctype=json&xmlVersion=**1.4&keyfrom=fanyi.web&ue=UTF- >>>> **8&typoResult=true&flag=false" \ >>>> | sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ; >>>> >>>> return 0; >>>> } >>>> >>>> 设置如下: >>>> linux用户: >>>> 1.添加此脚本到~/.bashrc的末尾 >>>> 2.source ~/.bashrc >>>> Mac osX用户: >>>> >>>> 1.添加此脚本到~/.bash_profile的末尾,**没有就新建 >>>> 2.source ~/.bash_profile >>>> >>>> 使用: >>>> >>>> >>>> Shell代码 >>>> $ ts hello >>>> 你好 >>>> $ ts "how are you?" >>>> 你好吗? >>>> >>>> 也可以翻译中文。 >>>> >>>> 原文地址 <http://hexlee.iteye.com/blog/1442506> >>>> >>> >>> 在 2012年3月23日星期五UTC+8下午11时26分10秒,Hex Lee写道: >>>> >>>> ts(){ >>>> >>>> curl -s \ >>>> "http://fanyi.youdao.com/**translate?smartresult=dict&** >>>> smartresult=rule&smartresult=**ugc&sessionFrom=dict.top<http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule&smartresult=ugc&sessionFrom=dict.top>" >>>> \ >>>> -d \ >>>> "type=AUTO& i=$1&doctype=json&xmlVersion=**1.4&keyfrom=fanyi.web&ue=UTF- >>>> **8&typoResult=true&flag=false" \ >>>> | sed -E -n 's/.*tgt":"([^"]+)".*/\1/p' ; >>>> >>>> return 0; >>>> } >>>> >>>> 设置如下: >>>> linux用户: >>>> 1.添加此脚本到~/.bashrc的末尾 >>>> 2.source ~/.bashrc >>>> Mac osX用户: >>>> >>>> 1.添加此脚本到~/.bash_profile的末尾,**没有就新建 >>>> 2.source ~/.bash_profile >>>> >>>> 使用: >>>> >>>> >>>> Shell代码 >>>> $ ts hello >>>> 你好 >>>> $ ts "how are you?" >>>> 你好吗? >>>> >>>> 也可以翻译中文。 >>>> >>>> 原文地址 <http://hexlee.iteye.com/blog/1442506> >>>> >>> >> > -------------- 下一部分 -------------- > 一个HTML附件被移除... > URL: > <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120512/d9eeb683/attachment.html> > -------------- 下一部分 -------------- > A non-text attachment was scrubbed... > Name: Screen Shot 2012-05-12 at 4.06.58 PM.png > Type: image/png > Size: 21389 bytes > Desc: 不可用 > URL: > <https://lists.ubuntu.com/archives/ubuntu-zh/attachments/20120512/d9eeb683/attachment.png> > -- > ubuntu-zh mailing list > ubuntu-zh@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh
-- ZZJIN@BUPT -- ubuntu-zh mailing list ubuntu-zh@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-zh