Using google as a dictionary lookup via bash, How can one grab the first definition?

大城市里の小女人 提交于 2019-12-03 17:05:52

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

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

Add this:

head -n 1 -q | tail -n 1

So it becomes:

#!/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 "*" | head -n 1 -q | tail -n 1

try head command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!