在终端上使用echo,grep,sed逐字Google搜索

・1 分钟阅读

在你的终端上逐字搜索

function google { Q="$@"; GOOG_URL='https://www.google.de/search?tbs=li:1&q='; AGENT="Mozilla/4.0"; stream=$(curl -A"$AGENT" -skLm 10"${GOOG_URL}${Q// /+}" | grep -oP '/url?q=.+?&amp' | sed 's|/url?q=||; s|&amp||'); echo -e"${stream//%/x}"; }
将它放在你的~/.bashrc中使用: google word1 word2 word3
示例输出
~$ google google IT Crowd
http://www.youtube.com/watch?v=iEwW6D0sht0
http://www.youtube.com/watch?v=iEwW6D0sht0
http://www.youtube.com/watch?v=OqxLmLUT-qc
http://www.youtube.com/watch?v=OqxLmLUT-qc
http://www.youtube.com/watch?v=qdjRwpYM-Kw
http://www.youtube.com/watch?v=qdjRwpYM-Kw
http://www.clipfish.de/video/3206679/the-it-crowd-google-googlen/
http://www.clipfish.de/video/3206679/the-it-crowd-google-googlen/
http://www.fanpop.com/clubs/the-it-crowd/quiz/vote?option_id=146989
http://en.wikiquote.org/wiki/The_IT_Crowd
http://www.serienjunkies.de/the-it-crowd/
http://theitcrowd-fic.livejournal.com/
https://play.google.com/store/apps/details?id=com.soundboard.itcrowd
https://plus.google.com/+AmandaBlain/posts/QgJcJM72UNs
Hujiuxiang profile image