使用google作为字典查找通过bash,如何可以抓住第一个定义? [英] Using google as a dictionary lookup via bash, How can one grab the first definition?

查看:142
本文介绍了使用google作为字典查找通过bash,如何可以抓住第一个定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#!/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转储一系列定义, p>

Dumps a whole series of definitions from google.com an example is below:

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"

t想要所有的定义,只是第一个:

Thing is, I don't want all the definitions, just the first one:

universe: everything that exists anywhere; "they study the evolution of the universe"; "the biggest tree in existence"

如何从输出中提取一个句子?它在两个*之间,可以使用?

How can a grab that sentence out from the output? Its between two *, could that be used?

推荐答案

这将剥离从第一行开始的项目符号,并舍弃输出的其余部分。

This will strip the bullet from the beginning of the first line, printing it and discarding the rest of the output.

sed 's/^ *\* *//; q'

这篇关于使用google作为字典查找通过bash,如何可以抓住第一个定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆