Si je veux connaître la signification de wget -b
, je vois le manuel par man wget
, puis cherche l'option -b
.
-b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
Je veux get le résultat par une command comme man wget -b
. (Bien sûr, cela ne fonctionne pas.)
Y a-t-il un moyen similaire pour le rendre possible?
Vous pouvez redirect la page de manuel vers awk
et extacter la partie:
man wget | awk '/^ *-b *.*$/,/^$/{print}' -b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
Cette partie est tout ce qui est entre -b
et une ligne vide.
Si vous utilisez less
de pager pour l'homme, vous pouvez essayer
LESS="+/^\s+-b" man wget
où
+
symbole pour exécuter l'opération suivante après l'ouverture de less
/
command pour lancer la search ^\s+-b
regexp pour correspondre à -b
partir du début de la ligne Donc, si vous le souhaitez, vous pouvez organiser la fonction appropriée pour shell
function rman { #USAGE: rman programm.name option.to.search (with "-" symbol) LESS="+/^\s+$2" man "$1" }
et l'append dans ~/.bashrc
par exemple.
Lorsque vous exécutez la man command
vous pouvez appuyer sur /
puis saisir le text brut à searchr. Par exemple, tapez /-b
et il passera à la première occurrence de -b
dans le text.
J'ai écrit un petit script pour le faire appelé il , par exemple, he wget -b
.
La stratégie de base consiste à: searchr l'option (par exemple -b
) comme premier mot sur une ligne, puis imprimer jusqu'à l'en-tête suivant ou la ligne suivante avec l'indentation correspondante.
Si vous ne pouvez pas utiliser cela, vous pouvez get quelque chose de similaire en utilisant basic sed
, par exemple
man wget | sed -ne '/^ *-b/,/^$/p'
J'utilise le script suivant qui se connecte à explainhell.com . Je l'ai copié depuis reddit il y a un certain time:
#!/bin/bash cmd=$1 shift args=$* args=${args/ /+} w3m -dump "http://explainshell.com/explain/$cmd?args=$args"
Je l'ai nommé rman
et l'ai mis dans mon $PATH
. Utilisation pour wget -b
:
$ rman wget -b [logo] • about • • [ ] wget(1) -b The non-interactive network downloader -b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log. source manpages: wget
Vous pouvez modifier ce script un peu pour ne pas montrer d'ordures au début.
EDIT: Je l'ai d' ici . Merci à l'auteur!
Sinon, si votre grep
est le grep
GNU, vous pouvez l'utiliser comme suit:
man wget | grep -EA3 '^ *-b'
Dans lequel -A
(une extension GNU) sert à imprimer le nombre de lignes après les lignes correspondantes (ici 3
). vous pouvez utiliser le numéro approprié pour la description complète.
Exemple:
$ man wget | grep -EA3 '^ *-b' -b --background Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log. $ man grep | grep -EA3 '^ *-A' -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.