Essayez cette sed
commande simple ,
$ man grep | sed -n '/-i, --ignore-case/,+2p'
-i, --ignore-case
Ignore case distinctions in both the PATTERN and the input
files. (-i is specified by POSIX.)
Explication:
sed -n '/-i, --ignore-case/,+2p'
|<-Search pattern->|
Il imprimera la ligne qui contient le motif de recherche ainsi que 2 lignes qui se présentent juste en dessous de la ligne du motif de recherche.
OU
Vous pouvez simplement donner uniquement les drapeaux dans le motif de recherche comme ci-dessous.
avinash@avinash-Lenovo-IdeaPad-Z500:~$ man grep | sed -n '/ *i, -/,+3p'
-i, --ignore-case
Ignore case distinctions in both the PATTERN and the input
files. (-i is specified by POSIX.)
avinash@avinash-Lenovo-IdeaPad-Z500:~$ man grep | sed -n '/ *V, -/,+3p'
-V, --version
Print the version number of grep to the standard output stream.
This version number should be included in all bug reports (see
below).
avinash@avinash-Lenovo-IdeaPad-Z500:~$ man grep | sed -n '/ *F, -/,+3p'
-F, --fixed-strings
Interpret PATTERN as a list of fixed strings, separated by
newlines, any of which is to be matched. (-F is specified by
POSIX.)
avinash@avinash-Lenovo-IdeaPad-Z500:~$ man grep | sed -n '/ *G, -/,+3p'
-G, --basic-regexp
Interpret PATTERN as a basic regular expression (BRE, see
below). This is the default.
Vous pouvez ajouter ce script à votre .bashrc
( $HOME/.bashrc
) pour un accès rapide:
mangrep(){
USAGE="mangrep <application> <switch>"
if [[ "$#" -ne "2" ]]
then
echo "Usage: $USAGE"
else
man "$1" | sed -n "/ *"$2", -/,+3p"
fi
}