Question

Voici un script de ligne de commande pour une recherche de dictionnaire à l'aide de 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 "*"

Je tape "Bonjour". voici la sortie:

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"

Je ne veux que la chaîne qui se trouve après le S :, rien avant. Je souhaite supprimer les éléments suivants:

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

Laisser cela pour la tuyauterie par lui-même - >

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

La solution 3

Je travaille avec un morceau de code qui ajoute à la réponse de 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 "\*\*\*\* "

Cela supprime tout le formatage, je crois. Il supprime également les lignes **** Noun **** .

Autres conseils

Je pense que si vous modifiez ce sed -e pour qu'il fasse s /^.* S: / / ou peut-être, pour être extrêmement prudent, s / ^ [^ S] * S: // vous obtiendrez ce que vous voulez. Si la commande sed se substitue à un onglet (je ne peux pas le dire), vous voudrez peut-être le préserver ...

Je ne sais pas ce que le grep "*" et est censé faire, mais vous pouvez le changer en:

grep -Eo '\(.*'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top