#!/bin/bash
# Command line look up using Google's define feature - command line dictionary
echo "Type in your word:"
read word
/usr/bin/curl -s -A 'Mozilla/4.0' 'http://www.google.com/search?q=define%3A+'$word \
| html2text -ascii -nobs -style compact -width 500 | grep "*"
从 google.com 转储一系列定义,示例如下:
Type in your word:
world
* universe: everything that exists anywhere; "they study the evolution of the universe"; "the biggest tree in existence"
* people in general; especially a distinctive group of people with some shared interest; "the Western world"
* all of your experiences that determine how things appear to you; "his world was shattered"; "we live in different worlds"; "for them demons were as much a part of reality as trees were"
问题是,我不需要所有的定义,只想要第一个:
universe: everything that exists anywhere; "they study the evolution of the universe"; "the biggest tree in existence"
如何从输出中抓取该句子?两个*之间可以用吗?
这将从第一行的开头剥离项目符号,打印它并丢弃其余的输出。
sed 's/^ *\* *//; q'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)