grep the man page of a command for hyphenated options












18















Suppose I want to know the usage of -i switch in grep command without scrolling. I need the specification just for that command or at least see the screen show that first. So how? As you can say that in general not just for grep -i.










share|improve this question




















  • 4





    learn searching in Vim

    – arsaKasra
    May 13 '14 at 22:31


















18















Suppose I want to know the usage of -i switch in grep command without scrolling. I need the specification just for that command or at least see the screen show that first. So how? As you can say that in general not just for grep -i.










share|improve this question




















  • 4





    learn searching in Vim

    – arsaKasra
    May 13 '14 at 22:31
















18












18








18


3






Suppose I want to know the usage of -i switch in grep command without scrolling. I need the specification just for that command or at least see the screen show that first. So how? As you can say that in general not just for grep -i.










share|improve this question
















Suppose I want to know the usage of -i switch in grep command without scrolling. I need the specification just for that command or at least see the screen show that first. So how? As you can say that in general not just for grep -i.







command-line manpage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 at 5:44









karel

59k13128149




59k13128149










asked May 11 '14 at 12:14









Mohammad Reza RezwaniMohammad Reza Rezwani

3,6692459110




3,6692459110








  • 4





    learn searching in Vim

    – arsaKasra
    May 13 '14 at 22:31
















  • 4





    learn searching in Vim

    – arsaKasra
    May 13 '14 at 22:31










4




4





learn searching in Vim

– arsaKasra
May 13 '14 at 22:31







learn searching in Vim

– arsaKasra
May 13 '14 at 22:31












11 Answers
11






active

oldest

votes


















13














Try this simple sed command,



$ 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.)


Explanation:



sed -n '/-i, --ignore-case/,+2p'

|<-Search pattern->|


It will print the line which contains the search pattern along with 2 lines which present just below to the search pattern line.



OR



You can simply give only the flags in the search patten like below.



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.


You can add this script to your .bashrc ($HOME/.bashrc) for quick access:



mangrep(){
USAGE="mangrep <application> <switch>"
if [[ "$#" -ne "2" ]]
then
echo "Usage: $USAGE"
else
man "$1" | sed -n "/ *"$2", -/,+3p"
fi
}





share|improve this answer

































    22














    Type the below command on terminal:



    man grep


    Then type slash character, /, and write your search, like -i, followed by Enter. This will position the cursor at the first occurrence of the search string. Pressing n moves the cursor to the next occurrence. Pressing Shift+n moves the cursor to the previous occurrence.






    share|improve this answer





















    • 1





      It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

      – Avinash Raj
      May 11 '14 at 12:57








    • 3





      @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

      – terdon
      May 11 '14 at 13:02



















    8














    While the simplest approach is to search with / as suggested by @girardengo, you can also use grep instead of sed which I find simpler:



    $ man grep | grep -A 1 '^ *-i'
    -i, --ignore-case
    Ignore case distinctions in both the PATTERN and the input
    files. (-i is specified by POSIX.)


    The -A N means "Print N lines after the matching one. Just a trick to get the next few lines, similar to Avinash's sed approach.






    share|improve this answer

































      3














      You can use the search function inside man, just pres "s", type the key you're looking for, (-i in your case) and press intro.






      share|improve this answer
























      • I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

        – Mohammad Reza Rezwani
        May 11 '14 at 12:27





















      3














      Or, you can let this site do the searching for you:



      http://explainshell.com/explain?cmd=grep+-i



      You have to switch from using the terminal to a browser for a bit, but there's ways around that too.






      share|improve this answer































        2














        The most efficient method I am aware of is to search the man page for -i (This site seems to fail to render my code. What I mean is <space><space><space>-i). That's 3 spaces (you may need more/less spaces) followed by the flag you're looking for. It almost always works in my experience, and you can change to some variant of it in cases where it doesn't work.



        It works because the actual documentation of the flags are typically indented. It avoids finding other mentions of the flag in other sections, because there's usually only one space before them.






        share|improve this answer

































          1














          Through all answers may be fine, but I think you are focusing in only a piece of documentation, not all. For example, to find the -i switch of the grep documentation:



          info grep Invoking Command-line Options Matching Control


          I will find all the information about "grep", how to "invoke" the specific "command-line options" for "matching control". Sadly it doesn't go more deeper than that, but it has -i, -y, --ignore-case in the firsts 25 lines, something reasonable that you don't have to scroll all your way down.



          This solution is the more flexible and also allows you to search all the infopages:



          info --apropos=--ignore-case
          "(coreutils)join invocation" -- --ignore-case <1>
          "(coreutils)uniq invocation" -- --ignore-case <2>
          "(coreutils)sort invocation" -- --ignore-case
          "(gettext)msggrep Invocation" -- --ignore-case, ‘msggrep’ option
          "(grep)Matching Control" -- --ignore-case


          (had to use --ignore-case instead of -i since it was too common, but you can just process the output to info in any case)



          In this case, you have both the name of the info page and the exact section. Ah, almost forgot, you can also just tab your way through most section of the info pages.






          share|improve this answer

































            1














            You can use Perl and its "paragraph mode" to extract only the relevant paragraph:



            man grep | perl -00 -ne 'print if / -i/'





            share|improve this answer































              1














              My favorite approach to find a given option in a man page is to use a regex like s{2,}-option. For the question in hand, you can do man grep and then type the regex:



              /s{3,}-i


              or



              / {3,}-i
              ^------------- space here


              This will match -i only when followed by three or more spaces.






              share|improve this answer

































                0














                As less is used by default as the pager for man, you can use the LESS environment variable to pass a pattern to search for when less opens the page. This is identical to doing e.g. man ls and then searching for the option --all or -a by typing / and then inputting the pattern e.g. --all or -a.



                All these can be done by:



                LESS='+/--all' man ls


                Or



                LESS='+/-a' man ls


                Input what you want to search after /.



                Presumably this works best for the long options (e.g. --all) compared to the short ones (e.g. -a).






                share|improve this answer































                  0














                  If you want to grep the man <program> results for a pattern beginning with a hyphen, use --
                  before the pattern you specify. Example using man find :



                  man find | grep -- -type


                  If you want more info, for example the entire section describing an
                  option, try using sed:



                  $ man find | sed -n '/-mindepth/,/^$/p'
                  -mindepth levels
                  Do not apply any tests or actions at levels less than levels (a
                  non-negative integer). -mindepth 1 means process all files
                  except the command line arguments.


                  Source






                  share|improve this answer























                    Your Answer








                    StackExchange.ready(function() {
                    var channelOptions = {
                    tags: "".split(" "),
                    id: "89"
                    };
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function() {
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled) {
                    StackExchange.using("snippets", function() {
                    createEditor();
                    });
                    }
                    else {
                    createEditor();
                    }
                    });

                    function createEditor() {
                    StackExchange.prepareEditor({
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader: {
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    },
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    });


                    }
                    });














                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f464302%2fgrep-the-man-page-of-a-command-for-hyphenated-options%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown

























                    11 Answers
                    11






                    active

                    oldest

                    votes








                    11 Answers
                    11






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    13














                    Try this simple sed command,



                    $ 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.)


                    Explanation:



                    sed -n '/-i, --ignore-case/,+2p'

                    |<-Search pattern->|


                    It will print the line which contains the search pattern along with 2 lines which present just below to the search pattern line.



                    OR



                    You can simply give only the flags in the search patten like below.



                    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.


                    You can add this script to your .bashrc ($HOME/.bashrc) for quick access:



                    mangrep(){
                    USAGE="mangrep <application> <switch>"
                    if [[ "$#" -ne "2" ]]
                    then
                    echo "Usage: $USAGE"
                    else
                    man "$1" | sed -n "/ *"$2", -/,+3p"
                    fi
                    }





                    share|improve this answer






























                      13














                      Try this simple sed command,



                      $ 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.)


                      Explanation:



                      sed -n '/-i, --ignore-case/,+2p'

                      |<-Search pattern->|


                      It will print the line which contains the search pattern along with 2 lines which present just below to the search pattern line.



                      OR



                      You can simply give only the flags in the search patten like below.



                      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.


                      You can add this script to your .bashrc ($HOME/.bashrc) for quick access:



                      mangrep(){
                      USAGE="mangrep <application> <switch>"
                      if [[ "$#" -ne "2" ]]
                      then
                      echo "Usage: $USAGE"
                      else
                      man "$1" | sed -n "/ *"$2", -/,+3p"
                      fi
                      }





                      share|improve this answer




























                        13












                        13








                        13







                        Try this simple sed command,



                        $ 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.)


                        Explanation:



                        sed -n '/-i, --ignore-case/,+2p'

                        |<-Search pattern->|


                        It will print the line which contains the search pattern along with 2 lines which present just below to the search pattern line.



                        OR



                        You can simply give only the flags in the search patten like below.



                        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.


                        You can add this script to your .bashrc ($HOME/.bashrc) for quick access:



                        mangrep(){
                        USAGE="mangrep <application> <switch>"
                        if [[ "$#" -ne "2" ]]
                        then
                        echo "Usage: $USAGE"
                        else
                        man "$1" | sed -n "/ *"$2", -/,+3p"
                        fi
                        }





                        share|improve this answer















                        Try this simple sed command,



                        $ 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.)


                        Explanation:



                        sed -n '/-i, --ignore-case/,+2p'

                        |<-Search pattern->|


                        It will print the line which contains the search pattern along with 2 lines which present just below to the search pattern line.



                        OR



                        You can simply give only the flags in the search patten like below.



                        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.


                        You can add this script to your .bashrc ($HOME/.bashrc) for quick access:



                        mangrep(){
                        USAGE="mangrep <application> <switch>"
                        if [[ "$#" -ne "2" ]]
                        then
                        echo "Usage: $USAGE"
                        else
                        man "$1" | sed -n "/ *"$2", -/,+3p"
                        fi
                        }






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 11 '14 at 14:32









                        Glutanimate

                        16.2k873132




                        16.2k873132










                        answered May 11 '14 at 12:20









                        Avinash RajAvinash Raj

                        51.8k41167217




                        51.8k41167217

























                            22














                            Type the below command on terminal:



                            man grep


                            Then type slash character, /, and write your search, like -i, followed by Enter. This will position the cursor at the first occurrence of the search string. Pressing n moves the cursor to the next occurrence. Pressing Shift+n moves the cursor to the previous occurrence.






                            share|improve this answer





















                            • 1





                              It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                              – Avinash Raj
                              May 11 '14 at 12:57








                            • 3





                              @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                              – terdon
                              May 11 '14 at 13:02
















                            22














                            Type the below command on terminal:



                            man grep


                            Then type slash character, /, and write your search, like -i, followed by Enter. This will position the cursor at the first occurrence of the search string. Pressing n moves the cursor to the next occurrence. Pressing Shift+n moves the cursor to the previous occurrence.






                            share|improve this answer





















                            • 1





                              It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                              – Avinash Raj
                              May 11 '14 at 12:57








                            • 3





                              @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                              – terdon
                              May 11 '14 at 13:02














                            22












                            22








                            22







                            Type the below command on terminal:



                            man grep


                            Then type slash character, /, and write your search, like -i, followed by Enter. This will position the cursor at the first occurrence of the search string. Pressing n moves the cursor to the next occurrence. Pressing Shift+n moves the cursor to the previous occurrence.






                            share|improve this answer















                            Type the below command on terminal:



                            man grep


                            Then type slash character, /, and write your search, like -i, followed by Enter. This will position the cursor at the first occurrence of the search string. Pressing n moves the cursor to the next occurrence. Pressing Shift+n moves the cursor to the previous occurrence.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited May 11 '14 at 20:20









                            unor

                            412322




                            412322










                            answered May 11 '14 at 12:34









                            girardengogirardengo

                            3,7621626




                            3,7621626








                            • 1





                              It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                              – Avinash Raj
                              May 11 '14 at 12:57








                            • 3





                              @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                              – terdon
                              May 11 '14 at 13:02














                            • 1





                              It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                              – Avinash Raj
                              May 11 '14 at 12:57








                            • 3





                              @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                              – terdon
                              May 11 '14 at 13:02








                            1




                            1





                            It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                            – Avinash Raj
                            May 11 '14 at 12:57







                            It will locate all the -i's the man grep page.But OP wants only the description related to -i flag in man page.

                            – Avinash Raj
                            May 11 '14 at 12:57






                            3




                            3





                            @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                            – terdon
                            May 11 '14 at 13:02





                            @AvinashRaj no, it will allow you to cycle through each occurrence of -i. That's exactly what the OP wants.

                            – terdon
                            May 11 '14 at 13:02











                            8














                            While the simplest approach is to search with / as suggested by @girardengo, you can also use grep instead of sed which I find simpler:



                            $ man grep | grep -A 1 '^ *-i'
                            -i, --ignore-case
                            Ignore case distinctions in both the PATTERN and the input
                            files. (-i is specified by POSIX.)


                            The -A N means "Print N lines after the matching one. Just a trick to get the next few lines, similar to Avinash's sed approach.






                            share|improve this answer






























                              8














                              While the simplest approach is to search with / as suggested by @girardengo, you can also use grep instead of sed which I find simpler:



                              $ man grep | grep -A 1 '^ *-i'
                              -i, --ignore-case
                              Ignore case distinctions in both the PATTERN and the input
                              files. (-i is specified by POSIX.)


                              The -A N means "Print N lines after the matching one. Just a trick to get the next few lines, similar to Avinash's sed approach.






                              share|improve this answer




























                                8












                                8








                                8







                                While the simplest approach is to search with / as suggested by @girardengo, you can also use grep instead of sed which I find simpler:



                                $ man grep | grep -A 1 '^ *-i'
                                -i, --ignore-case
                                Ignore case distinctions in both the PATTERN and the input
                                files. (-i is specified by POSIX.)


                                The -A N means "Print N lines after the matching one. Just a trick to get the next few lines, similar to Avinash's sed approach.






                                share|improve this answer















                                While the simplest approach is to search with / as suggested by @girardengo, you can also use grep instead of sed which I find simpler:



                                $ man grep | grep -A 1 '^ *-i'
                                -i, --ignore-case
                                Ignore case distinctions in both the PATTERN and the input
                                files. (-i is specified by POSIX.)


                                The -A N means "Print N lines after the matching one. Just a trick to get the next few lines, similar to Avinash's sed approach.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Apr 13 '17 at 12:25









                                Community

                                1




                                1










                                answered May 11 '14 at 13:03









                                terdonterdon

                                65.8k12138221




                                65.8k12138221























                                    3














                                    You can use the search function inside man, just pres "s", type the key you're looking for, (-i in your case) and press intro.






                                    share|improve this answer
























                                    • I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                      – Mohammad Reza Rezwani
                                      May 11 '14 at 12:27


















                                    3














                                    You can use the search function inside man, just pres "s", type the key you're looking for, (-i in your case) and press intro.






                                    share|improve this answer
























                                    • I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                      – Mohammad Reza Rezwani
                                      May 11 '14 at 12:27
















                                    3












                                    3








                                    3







                                    You can use the search function inside man, just pres "s", type the key you're looking for, (-i in your case) and press intro.






                                    share|improve this answer













                                    You can use the search function inside man, just pres "s", type the key you're looking for, (-i in your case) and press intro.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered May 11 '14 at 12:19









                                    animaletdesequiaanimaletdesequia

                                    6,64041938




                                    6,64041938













                                    • I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                      – Mohammad Reza Rezwani
                                      May 11 '14 at 12:27





















                                    • I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                      – Mohammad Reza Rezwani
                                      May 11 '14 at 12:27



















                                    I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                    – Mohammad Reza Rezwani
                                    May 11 '14 at 12:27







                                    I type man grep after that I press s after that I see log file: after that I type -i and ENTER but I do not see the description Or there is somthing which I do not know

                                    – Mohammad Reza Rezwani
                                    May 11 '14 at 12:27













                                    3














                                    Or, you can let this site do the searching for you:



                                    http://explainshell.com/explain?cmd=grep+-i



                                    You have to switch from using the terminal to a browser for a bit, but there's ways around that too.






                                    share|improve this answer




























                                      3














                                      Or, you can let this site do the searching for you:



                                      http://explainshell.com/explain?cmd=grep+-i



                                      You have to switch from using the terminal to a browser for a bit, but there's ways around that too.






                                      share|improve this answer


























                                        3












                                        3








                                        3







                                        Or, you can let this site do the searching for you:



                                        http://explainshell.com/explain?cmd=grep+-i



                                        You have to switch from using the terminal to a browser for a bit, but there's ways around that too.






                                        share|improve this answer













                                        Or, you can let this site do the searching for you:



                                        http://explainshell.com/explain?cmd=grep+-i



                                        You have to switch from using the terminal to a browser for a bit, but there's ways around that too.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered May 13 '14 at 23:14









                                        TomTom

                                        274313




                                        274313























                                            2














                                            The most efficient method I am aware of is to search the man page for -i (This site seems to fail to render my code. What I mean is <space><space><space>-i). That's 3 spaces (you may need more/less spaces) followed by the flag you're looking for. It almost always works in my experience, and you can change to some variant of it in cases where it doesn't work.



                                            It works because the actual documentation of the flags are typically indented. It avoids finding other mentions of the flag in other sections, because there's usually only one space before them.






                                            share|improve this answer






























                                              2














                                              The most efficient method I am aware of is to search the man page for -i (This site seems to fail to render my code. What I mean is <space><space><space>-i). That's 3 spaces (you may need more/less spaces) followed by the flag you're looking for. It almost always works in my experience, and you can change to some variant of it in cases where it doesn't work.



                                              It works because the actual documentation of the flags are typically indented. It avoids finding other mentions of the flag in other sections, because there's usually only one space before them.






                                              share|improve this answer




























                                                2












                                                2








                                                2







                                                The most efficient method I am aware of is to search the man page for -i (This site seems to fail to render my code. What I mean is <space><space><space>-i). That's 3 spaces (you may need more/less spaces) followed by the flag you're looking for. It almost always works in my experience, and you can change to some variant of it in cases where it doesn't work.



                                                It works because the actual documentation of the flags are typically indented. It avoids finding other mentions of the flag in other sections, because there's usually only one space before them.






                                                share|improve this answer















                                                The most efficient method I am aware of is to search the man page for -i (This site seems to fail to render my code. What I mean is <space><space><space>-i). That's 3 spaces (you may need more/less spaces) followed by the flag you're looking for. It almost always works in my experience, and you can change to some variant of it in cases where it doesn't work.



                                                It works because the actual documentation of the flags are typically indented. It avoids finding other mentions of the flag in other sections, because there's usually only one space before them.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited May 11 '14 at 19:39

























                                                answered May 11 '14 at 19:32









                                                Harold R. EasonHarold R. Eason

                                                1212




                                                1212























                                                    1














                                                    Through all answers may be fine, but I think you are focusing in only a piece of documentation, not all. For example, to find the -i switch of the grep documentation:



                                                    info grep Invoking Command-line Options Matching Control


                                                    I will find all the information about "grep", how to "invoke" the specific "command-line options" for "matching control". Sadly it doesn't go more deeper than that, but it has -i, -y, --ignore-case in the firsts 25 lines, something reasonable that you don't have to scroll all your way down.



                                                    This solution is the more flexible and also allows you to search all the infopages:



                                                    info --apropos=--ignore-case
                                                    "(coreutils)join invocation" -- --ignore-case <1>
                                                    "(coreutils)uniq invocation" -- --ignore-case <2>
                                                    "(coreutils)sort invocation" -- --ignore-case
                                                    "(gettext)msggrep Invocation" -- --ignore-case, ‘msggrep’ option
                                                    "(grep)Matching Control" -- --ignore-case


                                                    (had to use --ignore-case instead of -i since it was too common, but you can just process the output to info in any case)



                                                    In this case, you have both the name of the info page and the exact section. Ah, almost forgot, you can also just tab your way through most section of the info pages.






                                                    share|improve this answer






























                                                      1














                                                      Through all answers may be fine, but I think you are focusing in only a piece of documentation, not all. For example, to find the -i switch of the grep documentation:



                                                      info grep Invoking Command-line Options Matching Control


                                                      I will find all the information about "grep", how to "invoke" the specific "command-line options" for "matching control". Sadly it doesn't go more deeper than that, but it has -i, -y, --ignore-case in the firsts 25 lines, something reasonable that you don't have to scroll all your way down.



                                                      This solution is the more flexible and also allows you to search all the infopages:



                                                      info --apropos=--ignore-case
                                                      "(coreutils)join invocation" -- --ignore-case <1>
                                                      "(coreutils)uniq invocation" -- --ignore-case <2>
                                                      "(coreutils)sort invocation" -- --ignore-case
                                                      "(gettext)msggrep Invocation" -- --ignore-case, ‘msggrep’ option
                                                      "(grep)Matching Control" -- --ignore-case


                                                      (had to use --ignore-case instead of -i since it was too common, but you can just process the output to info in any case)



                                                      In this case, you have both the name of the info page and the exact section. Ah, almost forgot, you can also just tab your way through most section of the info pages.






                                                      share|improve this answer




























                                                        1












                                                        1








                                                        1







                                                        Through all answers may be fine, but I think you are focusing in only a piece of documentation, not all. For example, to find the -i switch of the grep documentation:



                                                        info grep Invoking Command-line Options Matching Control


                                                        I will find all the information about "grep", how to "invoke" the specific "command-line options" for "matching control". Sadly it doesn't go more deeper than that, but it has -i, -y, --ignore-case in the firsts 25 lines, something reasonable that you don't have to scroll all your way down.



                                                        This solution is the more flexible and also allows you to search all the infopages:



                                                        info --apropos=--ignore-case
                                                        "(coreutils)join invocation" -- --ignore-case <1>
                                                        "(coreutils)uniq invocation" -- --ignore-case <2>
                                                        "(coreutils)sort invocation" -- --ignore-case
                                                        "(gettext)msggrep Invocation" -- --ignore-case, ‘msggrep’ option
                                                        "(grep)Matching Control" -- --ignore-case


                                                        (had to use --ignore-case instead of -i since it was too common, but you can just process the output to info in any case)



                                                        In this case, you have both the name of the info page and the exact section. Ah, almost forgot, you can also just tab your way through most section of the info pages.






                                                        share|improve this answer















                                                        Through all answers may be fine, but I think you are focusing in only a piece of documentation, not all. For example, to find the -i switch of the grep documentation:



                                                        info grep Invoking Command-line Options Matching Control


                                                        I will find all the information about "grep", how to "invoke" the specific "command-line options" for "matching control". Sadly it doesn't go more deeper than that, but it has -i, -y, --ignore-case in the firsts 25 lines, something reasonable that you don't have to scroll all your way down.



                                                        This solution is the more flexible and also allows you to search all the infopages:



                                                        info --apropos=--ignore-case
                                                        "(coreutils)join invocation" -- --ignore-case <1>
                                                        "(coreutils)uniq invocation" -- --ignore-case <2>
                                                        "(coreutils)sort invocation" -- --ignore-case
                                                        "(gettext)msggrep Invocation" -- --ignore-case, ‘msggrep’ option
                                                        "(grep)Matching Control" -- --ignore-case


                                                        (had to use --ignore-case instead of -i since it was too common, but you can just process the output to info in any case)



                                                        In this case, you have both the name of the info page and the exact section. Ah, almost forgot, you can also just tab your way through most section of the info pages.







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited May 12 '14 at 4:52

























                                                        answered May 12 '14 at 4:46









                                                        BraiamBraiam

                                                        51.8k20136221




                                                        51.8k20136221























                                                            1














                                                            You can use Perl and its "paragraph mode" to extract only the relevant paragraph:



                                                            man grep | perl -00 -ne 'print if / -i/'





                                                            share|improve this answer




























                                                              1














                                                              You can use Perl and its "paragraph mode" to extract only the relevant paragraph:



                                                              man grep | perl -00 -ne 'print if / -i/'





                                                              share|improve this answer


























                                                                1












                                                                1








                                                                1







                                                                You can use Perl and its "paragraph mode" to extract only the relevant paragraph:



                                                                man grep | perl -00 -ne 'print if / -i/'





                                                                share|improve this answer













                                                                You can use Perl and its "paragraph mode" to extract only the relevant paragraph:



                                                                man grep | perl -00 -ne 'print if / -i/'






                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered Mar 8 '16 at 17:17









                                                                chorobachoroba

                                                                6,63411730




                                                                6,63411730























                                                                    1














                                                                    My favorite approach to find a given option in a man page is to use a regex like s{2,}-option. For the question in hand, you can do man grep and then type the regex:



                                                                    /s{3,}-i


                                                                    or



                                                                    / {3,}-i
                                                                    ^------------- space here


                                                                    This will match -i only when followed by three or more spaces.






                                                                    share|improve this answer






























                                                                      1














                                                                      My favorite approach to find a given option in a man page is to use a regex like s{2,}-option. For the question in hand, you can do man grep and then type the regex:



                                                                      /s{3,}-i


                                                                      or



                                                                      / {3,}-i
                                                                      ^------------- space here


                                                                      This will match -i only when followed by three or more spaces.






                                                                      share|improve this answer




























                                                                        1












                                                                        1








                                                                        1







                                                                        My favorite approach to find a given option in a man page is to use a regex like s{2,}-option. For the question in hand, you can do man grep and then type the regex:



                                                                        /s{3,}-i


                                                                        or



                                                                        / {3,}-i
                                                                        ^------------- space here


                                                                        This will match -i only when followed by three or more spaces.






                                                                        share|improve this answer















                                                                        My favorite approach to find a given option in a man page is to use a regex like s{2,}-option. For the question in hand, you can do man grep and then type the regex:



                                                                        /s{3,}-i


                                                                        or



                                                                        / {3,}-i
                                                                        ^------------- space here


                                                                        This will match -i only when followed by three or more spaces.







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Apr 23 '18 at 21:25

























                                                                        answered Apr 23 '18 at 21:17









                                                                        SergioSergio

                                                                        1114




                                                                        1114























                                                                            0














                                                                            As less is used by default as the pager for man, you can use the LESS environment variable to pass a pattern to search for when less opens the page. This is identical to doing e.g. man ls and then searching for the option --all or -a by typing / and then inputting the pattern e.g. --all or -a.



                                                                            All these can be done by:



                                                                            LESS='+/--all' man ls


                                                                            Or



                                                                            LESS='+/-a' man ls


                                                                            Input what you want to search after /.



                                                                            Presumably this works best for the long options (e.g. --all) compared to the short ones (e.g. -a).






                                                                            share|improve this answer




























                                                                              0














                                                                              As less is used by default as the pager for man, you can use the LESS environment variable to pass a pattern to search for when less opens the page. This is identical to doing e.g. man ls and then searching for the option --all or -a by typing / and then inputting the pattern e.g. --all or -a.



                                                                              All these can be done by:



                                                                              LESS='+/--all' man ls


                                                                              Or



                                                                              LESS='+/-a' man ls


                                                                              Input what you want to search after /.



                                                                              Presumably this works best for the long options (e.g. --all) compared to the short ones (e.g. -a).






                                                                              share|improve this answer


























                                                                                0












                                                                                0








                                                                                0







                                                                                As less is used by default as the pager for man, you can use the LESS environment variable to pass a pattern to search for when less opens the page. This is identical to doing e.g. man ls and then searching for the option --all or -a by typing / and then inputting the pattern e.g. --all or -a.



                                                                                All these can be done by:



                                                                                LESS='+/--all' man ls


                                                                                Or



                                                                                LESS='+/-a' man ls


                                                                                Input what you want to search after /.



                                                                                Presumably this works best for the long options (e.g. --all) compared to the short ones (e.g. -a).






                                                                                share|improve this answer













                                                                                As less is used by default as the pager for man, you can use the LESS environment variable to pass a pattern to search for when less opens the page. This is identical to doing e.g. man ls and then searching for the option --all or -a by typing / and then inputting the pattern e.g. --all or -a.



                                                                                All these can be done by:



                                                                                LESS='+/--all' man ls


                                                                                Or



                                                                                LESS='+/-a' man ls


                                                                                Input what you want to search after /.



                                                                                Presumably this works best for the long options (e.g. --all) compared to the short ones (e.g. -a).







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Jul 26 '16 at 16:00









                                                                                heemaylheemayl

                                                                                66.6k8140213




                                                                                66.6k8140213























                                                                                    0














                                                                                    If you want to grep the man <program> results for a pattern beginning with a hyphen, use --
                                                                                    before the pattern you specify. Example using man find :



                                                                                    man find | grep -- -type


                                                                                    If you want more info, for example the entire section describing an
                                                                                    option, try using sed:



                                                                                    $ man find | sed -n '/-mindepth/,/^$/p'
                                                                                    -mindepth levels
                                                                                    Do not apply any tests or actions at levels less than levels (a
                                                                                    non-negative integer). -mindepth 1 means process all files
                                                                                    except the command line arguments.


                                                                                    Source






                                                                                    share|improve this answer




























                                                                                      0














                                                                                      If you want to grep the man <program> results for a pattern beginning with a hyphen, use --
                                                                                      before the pattern you specify. Example using man find :



                                                                                      man find | grep -- -type


                                                                                      If you want more info, for example the entire section describing an
                                                                                      option, try using sed:



                                                                                      $ man find | sed -n '/-mindepth/,/^$/p'
                                                                                      -mindepth levels
                                                                                      Do not apply any tests or actions at levels less than levels (a
                                                                                      non-negative integer). -mindepth 1 means process all files
                                                                                      except the command line arguments.


                                                                                      Source






                                                                                      share|improve this answer


























                                                                                        0












                                                                                        0








                                                                                        0







                                                                                        If you want to grep the man <program> results for a pattern beginning with a hyphen, use --
                                                                                        before the pattern you specify. Example using man find :



                                                                                        man find | grep -- -type


                                                                                        If you want more info, for example the entire section describing an
                                                                                        option, try using sed:



                                                                                        $ man find | sed -n '/-mindepth/,/^$/p'
                                                                                        -mindepth levels
                                                                                        Do not apply any tests or actions at levels less than levels (a
                                                                                        non-negative integer). -mindepth 1 means process all files
                                                                                        except the command line arguments.


                                                                                        Source






                                                                                        share|improve this answer













                                                                                        If you want to grep the man <program> results for a pattern beginning with a hyphen, use --
                                                                                        before the pattern you specify. Example using man find :



                                                                                        man find | grep -- -type


                                                                                        If you want more info, for example the entire section describing an
                                                                                        option, try using sed:



                                                                                        $ man find | sed -n '/-mindepth/,/^$/p'
                                                                                        -mindepth levels
                                                                                        Do not apply any tests or actions at levels less than levels (a
                                                                                        non-negative integer). -mindepth 1 means process all files
                                                                                        except the command line arguments.


                                                                                        Source







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Jan 21 at 5:44









                                                                                        karelkarel

                                                                                        59k13128149




                                                                                        59k13128149






























                                                                                            draft saved

                                                                                            draft discarded




















































                                                                                            Thanks for contributing an answer to Ask Ubuntu!


                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                            But avoid



                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                            To learn more, see our tips on writing great answers.




                                                                                            draft saved


                                                                                            draft discarded














                                                                                            StackExchange.ready(
                                                                                            function () {
                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f464302%2fgrep-the-man-page-of-a-command-for-hyphenated-options%23new-answer', 'question_page');
                                                                                            }
                                                                                            );

                                                                                            Post as a guest















                                                                                            Required, but never shown





















































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown

































                                                                                            Required, but never shown














                                                                                            Required, but never shown












                                                                                            Required, but never shown







                                                                                            Required, but never shown







                                                                                            Popular posts from this blog

                                                                                            How to make a Squid Proxy server?

                                                                                            第一次世界大戦

                                                                                            Touch on Surface Book