Sed 仅显示和管道传输流中的特定文本行

Sed 仅显示和管道传输流中的特定文本行,sed,awk,grep,lookup,wordnet,Sed,Awk,Grep,Lookup,Wordnet,以下是使用Wordnet查找字典的命令行脚本: #!/bin/bash # Command line look up using Wordnet - command line dictionary echo "Type in your word:" read word /usr/bin/curl -s -A 'Mozilla/4.0' 'http://wordnetweb.princeton.edu/perl/webwn?s='$word'&sub=Search+WordNet&a

以下是使用Wordnet查找字典的命令行脚本:

#!/bin/bash
# Command line look up using Wordnet - command line dictionary

echo "Type in your word:"
read word

/usr/bin/curl -s -A 'Mozilla/4.0'  'http://wordnetweb.princeton.edu/perl/webwn?s='$word'&sub=Search+WordNet&o2=&o0=1&o7=&o5=&o1=1&o6=&o4=&o3=&h=' \
| html2text -ascii -nobs -style compact -width 500 | grep "*"
我输入“hello”,这是输出:

Type in your word:
hello
**** Noun ****
    * S:(n)hello, hullo, hi, howdy, how-do-you-do (an expression of greeting) "every morning they exchanged polite hellos"
我只想要S:后面的字符串,前面什么都不要。我想删除以下内容:

**** Noun ****
    * S:
将其留给管道本身->

(n)hello, hullo, hi, howdy, how-do-you-do (an expression of greeting) "every morning they exchanged polite hellos"

我相信,如果你把sed-e改成
s/^.*s://
,或者,为了更加小心,
s/^[^s]*s://
,你会得到你想要的。如果sed命令正在替换一个选项卡(我不知道),那么您可能希望保留该选项卡…

我不知道
grep“*”
的作用,但是您可以将其更改为:

grep -Eo '\(.*'

我有一段代码正在工作,它补充了DigitalRoss的答案:

#!/bin/bash
# Command line look up using Wordnet - command line dictionary

echo "Type in your word:"
read word

/usr/bin/curl -s -A 'Mozilla/4.0'  'http://wordnetweb.princeton.edu/perl/webwn?s='$word'&sub=Search+WordNet&o2=&o0=1&o7=&o5=&o1=1&o6=&o4=&o3=&h=' \
| html2text -ascii -nobs -style compact -width 500 | grep "*" | sed 's/^[^S]*S://' | grep -v "\*\*\*\* "

它删除了我相信的所有格式。它还删除了
****名词****
行。

删除了S:,但不删除****名词****以及。grep“*”-从站点获取定义-否则您将获取标题-或其他无用信息。