How to indicate start of line in less search of man pages?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I frequently refer to man bash to recall use of "history expansion" parts(events/words/modifiers). I know that the man part I need is
"HISTORY EXPANSION". So I type in HISTORY EXPANSION in forward search list '/'. Of course less jumps not straightforward to the "HISTORY EXPANSION" part, but instead shows all occurrences of this string in given man. Thus, I thought it would be great to type something like:



/^HISTORY EXPANSION


so I could jump to "start of line"HISTORY EXPANSION.



Neither /^HISTORY EXPANSION nor /^HISTORY EXPANSION work



In less man I see that
...




/pattern

Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system.




I see that other men were also looking into this, but with a different purpose:
https://stackoverflow.com/questions/14698364/what-is-the-regular-expression-library-supplied-by-my-system



I followed the steps, but still cannot say for sure what regex version is used on my machine. Here is the shared lib dependencies output for less binary



$ ldd /usr/bin/less
linux-vdso.so.1 => (0x00007ffc229cb000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f44968e9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4496524000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4496b12000)


So, how to indicate start of line in less search, so I can easily jump to the parts of man I need?







share|improve this question


















  • 1




    Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
    – Kusalananda
    Jan 22 at 11:09











  • man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
    – Stéphane Chazelas
    Jan 22 at 11:10










  • Possibly related: Grep: unexpected results when searching for words in heading from man page
    – Stéphane Chazelas
    Jan 22 at 11:11










  • IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
    – Stéphane Chazelas
    Jan 22 at 11:28










  • @Kusalananda set PAGER=more, and your search will fail.
    – Gerard H. Pille
    Jan 22 at 11:29














up vote
3
down vote

favorite












I frequently refer to man bash to recall use of "history expansion" parts(events/words/modifiers). I know that the man part I need is
"HISTORY EXPANSION". So I type in HISTORY EXPANSION in forward search list '/'. Of course less jumps not straightforward to the "HISTORY EXPANSION" part, but instead shows all occurrences of this string in given man. Thus, I thought it would be great to type something like:



/^HISTORY EXPANSION


so I could jump to "start of line"HISTORY EXPANSION.



Neither /^HISTORY EXPANSION nor /^HISTORY EXPANSION work



In less man I see that
...




/pattern

Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system.




I see that other men were also looking into this, but with a different purpose:
https://stackoverflow.com/questions/14698364/what-is-the-regular-expression-library-supplied-by-my-system



I followed the steps, but still cannot say for sure what regex version is used on my machine. Here is the shared lib dependencies output for less binary



$ ldd /usr/bin/less
linux-vdso.so.1 => (0x00007ffc229cb000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f44968e9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4496524000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4496b12000)


So, how to indicate start of line in less search, so I can easily jump to the parts of man I need?







share|improve this question


















  • 1




    Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
    – Kusalananda
    Jan 22 at 11:09











  • man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
    – Stéphane Chazelas
    Jan 22 at 11:10










  • Possibly related: Grep: unexpected results when searching for words in heading from man page
    – Stéphane Chazelas
    Jan 22 at 11:11










  • IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
    – Stéphane Chazelas
    Jan 22 at 11:28










  • @Kusalananda set PAGER=more, and your search will fail.
    – Gerard H. Pille
    Jan 22 at 11:29












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I frequently refer to man bash to recall use of "history expansion" parts(events/words/modifiers). I know that the man part I need is
"HISTORY EXPANSION". So I type in HISTORY EXPANSION in forward search list '/'. Of course less jumps not straightforward to the "HISTORY EXPANSION" part, but instead shows all occurrences of this string in given man. Thus, I thought it would be great to type something like:



/^HISTORY EXPANSION


so I could jump to "start of line"HISTORY EXPANSION.



Neither /^HISTORY EXPANSION nor /^HISTORY EXPANSION work



In less man I see that
...




/pattern

Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system.




I see that other men were also looking into this, but with a different purpose:
https://stackoverflow.com/questions/14698364/what-is-the-regular-expression-library-supplied-by-my-system



I followed the steps, but still cannot say for sure what regex version is used on my machine. Here is the shared lib dependencies output for less binary



$ ldd /usr/bin/less
linux-vdso.so.1 => (0x00007ffc229cb000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f44968e9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4496524000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4496b12000)


So, how to indicate start of line in less search, so I can easily jump to the parts of man I need?







share|improve this question














I frequently refer to man bash to recall use of "history expansion" parts(events/words/modifiers). I know that the man part I need is
"HISTORY EXPANSION". So I type in HISTORY EXPANSION in forward search list '/'. Of course less jumps not straightforward to the "HISTORY EXPANSION" part, but instead shows all occurrences of this string in given man. Thus, I thought it would be great to type something like:



/^HISTORY EXPANSION


so I could jump to "start of line"HISTORY EXPANSION.



Neither /^HISTORY EXPANSION nor /^HISTORY EXPANSION work



In less man I see that
...




/pattern

Search forward in the file for the N-th line containing the pattern. N defaults to 1. The pattern is a regular expression, as recognized by the regular expression library supplied by your system.




I see that other men were also looking into this, but with a different purpose:
https://stackoverflow.com/questions/14698364/what-is-the-regular-expression-library-supplied-by-my-system



I followed the steps, but still cannot say for sure what regex version is used on my machine. Here is the shared lib dependencies output for less binary



$ ldd /usr/bin/less
linux-vdso.so.1 => (0x00007ffc229cb000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f44968e9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4496524000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4496b12000)


So, how to indicate start of line in less search, so I can easily jump to the parts of man I need?









share|improve this question













share|improve this question




share|improve this question








edited Jan 22 at 12:05









Gerard H. Pille

1,219212




1,219212










asked Jan 22 at 11:05









ortymd

385




385







  • 1




    Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
    – Kusalananda
    Jan 22 at 11:09











  • man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
    – Stéphane Chazelas
    Jan 22 at 11:10










  • Possibly related: Grep: unexpected results when searching for words in heading from man page
    – Stéphane Chazelas
    Jan 22 at 11:11










  • IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
    – Stéphane Chazelas
    Jan 22 at 11:28










  • @Kusalananda set PAGER=more, and your search will fail.
    – Gerard H. Pille
    Jan 22 at 11:29












  • 1




    Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
    – Kusalananda
    Jan 22 at 11:09











  • man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
    – Stéphane Chazelas
    Jan 22 at 11:10










  • Possibly related: Grep: unexpected results when searching for words in heading from man page
    – Stéphane Chazelas
    Jan 22 at 11:11










  • IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
    – Stéphane Chazelas
    Jan 22 at 11:28










  • @Kusalananda set PAGER=more, and your search will fail.
    – Gerard H. Pille
    Jan 22 at 11:29







1




1




Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
– Kusalananda
Jan 22 at 11:09





Typing /^HISTORY EX followed by return works for me in the manual of bash on a Linux system. I can't reproduce your issue.
– Kusalananda
Jan 22 at 11:09













man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
– Stéphane Chazelas
Jan 22 at 11:10




man is not really appropriate for a manual this big. I would recommand formats with support for index and/or table of content, like info with which you have a searchable index (i, then type history expansion with tab completion)
– Stéphane Chazelas
Jan 22 at 11:10












Possibly related: Grep: unexpected results when searching for words in heading from man page
– Stéphane Chazelas
Jan 22 at 11:11




Possibly related: Grep: unexpected results when searching for words in heading from man page
– Stéphane Chazelas
Jan 22 at 11:11












IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
– Stéphane Chazelas
Jan 22 at 11:28




IOW, I can reproduce your issue if I run man as GROFF_SGR=1 MANPAGER='less -r' man bash. You'd want to make sure less is run with -R instead of -r (for it do understand those SGR escape sequences as opposed to pass them through), or use GROFF_NO_SGR to revert to the traditional way of doing bold/underline.
– Stéphane Chazelas
Jan 22 at 11:28












@Kusalananda set PAGER=more, and your search will fail.
– Gerard H. Pille
Jan 22 at 11:29




@Kusalananda set PAGER=more, and your search will fail.
– Gerard H. Pille
Jan 22 at 11:29










2 Answers
2






active

oldest

votes

















up vote
1
down vote













When man's output passes through more, each bold character is in fact that character, followed by a backspace, followed by repeating that character and then to the next character. To find something in bold, search for /^H..I..S..T



You'll find it also in the article Stéphane pointed to.






share|improve this answer
















  • 1




    But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
    – Stéphane Chazelas
    Jan 22 at 11:31

















up vote
0
down vote



accepted










Having tried and experimented it appears that man actually indents lines with spaces. This is the reason I could find
/^HISTORY EXPANSION
and failed with
/^The history library(This is the first sentence in HISTORY EXPANSION section). Here is the correct pattern:
/^[[:space:]]7The history library...

As we can see man/less simply adds 7 "spaces"(ascii dec code 32) in front of each line that is not a section header (in bold, as I see other people speak).
I cannot say for sure whether this is true with all Linux distros/man binaries, but with all I tested so far this is true. To sum up in order to find(from first search) description of '-atime' option in man find use
/^[[:space:]]7-atime






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418829%2fhow-to-indicate-start-of-line-in-less-search-of-man-pages%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    When man's output passes through more, each bold character is in fact that character, followed by a backspace, followed by repeating that character and then to the next character. To find something in bold, search for /^H..I..S..T



    You'll find it also in the article Stéphane pointed to.






    share|improve this answer
















    • 1




      But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
      – Stéphane Chazelas
      Jan 22 at 11:31














    up vote
    1
    down vote













    When man's output passes through more, each bold character is in fact that character, followed by a backspace, followed by repeating that character and then to the next character. To find something in bold, search for /^H..I..S..T



    You'll find it also in the article Stéphane pointed to.






    share|improve this answer
















    • 1




      But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
      – Stéphane Chazelas
      Jan 22 at 11:31












    up vote
    1
    down vote










    up vote
    1
    down vote









    When man's output passes through more, each bold character is in fact that character, followed by a backspace, followed by repeating that character and then to the next character. To find something in bold, search for /^H..I..S..T



    You'll find it also in the article Stéphane pointed to.






    share|improve this answer












    When man's output passes through more, each bold character is in fact that character, followed by a backspace, followed by repeating that character and then to the next character. To find something in bold, search for /^H..I..S..T



    You'll find it also in the article Stéphane pointed to.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 22 at 11:29









    Gerard H. Pille

    1,219212




    1,219212







    • 1




      But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
      – Stéphane Chazelas
      Jan 22 at 11:31












    • 1




      But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
      – Stéphane Chazelas
      Jan 22 at 11:31







    1




    1




    But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
    – Stéphane Chazelas
    Jan 22 at 11:31




    But less understands those and its search facility will work on the rendered text. It's different though when roff uses SGR escape sequences for bold/underline and less is called with -r.
    – Stéphane Chazelas
    Jan 22 at 11:31












    up vote
    0
    down vote



    accepted










    Having tried and experimented it appears that man actually indents lines with spaces. This is the reason I could find
    /^HISTORY EXPANSION
    and failed with
    /^The history library(This is the first sentence in HISTORY EXPANSION section). Here is the correct pattern:
    /^[[:space:]]7The history library...

    As we can see man/less simply adds 7 "spaces"(ascii dec code 32) in front of each line that is not a section header (in bold, as I see other people speak).
    I cannot say for sure whether this is true with all Linux distros/man binaries, but with all I tested so far this is true. To sum up in order to find(from first search) description of '-atime' option in man find use
    /^[[:space:]]7-atime






    share|improve this answer
























      up vote
      0
      down vote



      accepted










      Having tried and experimented it appears that man actually indents lines with spaces. This is the reason I could find
      /^HISTORY EXPANSION
      and failed with
      /^The history library(This is the first sentence in HISTORY EXPANSION section). Here is the correct pattern:
      /^[[:space:]]7The history library...

      As we can see man/less simply adds 7 "spaces"(ascii dec code 32) in front of each line that is not a section header (in bold, as I see other people speak).
      I cannot say for sure whether this is true with all Linux distros/man binaries, but with all I tested so far this is true. To sum up in order to find(from first search) description of '-atime' option in man find use
      /^[[:space:]]7-atime






      share|improve this answer






















        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Having tried and experimented it appears that man actually indents lines with spaces. This is the reason I could find
        /^HISTORY EXPANSION
        and failed with
        /^The history library(This is the first sentence in HISTORY EXPANSION section). Here is the correct pattern:
        /^[[:space:]]7The history library...

        As we can see man/less simply adds 7 "spaces"(ascii dec code 32) in front of each line that is not a section header (in bold, as I see other people speak).
        I cannot say for sure whether this is true with all Linux distros/man binaries, but with all I tested so far this is true. To sum up in order to find(from first search) description of '-atime' option in man find use
        /^[[:space:]]7-atime






        share|improve this answer












        Having tried and experimented it appears that man actually indents lines with spaces. This is the reason I could find
        /^HISTORY EXPANSION
        and failed with
        /^The history library(This is the first sentence in HISTORY EXPANSION section). Here is the correct pattern:
        /^[[:space:]]7The history library...

        As we can see man/less simply adds 7 "spaces"(ascii dec code 32) in front of each line that is not a section header (in bold, as I see other people speak).
        I cannot say for sure whether this is true with all Linux distros/man binaries, but with all I tested so far this is true. To sum up in order to find(from first search) description of '-atime' option in man find use
        /^[[:space:]]7-atime







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 24 at 17:39









        ortymd

        385




        385






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418829%2fhow-to-indicate-start-of-line-in-less-search-of-man-pages%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay