Frage

Hier ist ein Kommandozeilen-Skript für ein Nachschlagen im Wörterbuch mit 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 "*"

Ich tippe in "Hallo" hier ist die Ausgabe:

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"

Ich möchte nur die Zeichenfolge, die nach dem S :, nichts, bevor es ist. Ich möchte folgendes entfernen:

**** Noun ****
    * S:

Verlassen dies für Rohrleitungen selbst ->

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

Lösung 3

Ich habe ein Stück Code Arbeits bekam, die auf die Antwort von DigitalRoss fügt hinzu:

#!/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 "\*\*\*\* "

Es entfernt alle Formatierungen, glaube ich. Es entfernt die **** Noun **** Linien als auch.

Andere Tipps

Ich glaube, dass, wenn Sie diese sed -e ändern s/^.*S:/ / oder vielleicht zu tun, um besonders vorsichtig zu sein, s/^[^S]*S:// Sie bekommen, was Sie wollen. Wenn der Befehl sed eine Registerkarte ersetzen (ich kann nicht sagen), dann können Sie das bewahren ...

Ich weiß nicht, was der grep "*" tun soll, aber man kann es ändern:

grep -Eo '\(.*'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top