Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.linux.suse > #24753

Re: Text-Searching in "less"

From "Carlos E.R." <robin_listas@es.invalid>
Newsgroups alt.os.linux.suse
Subject Re: Text-Searching in "less"
Date 2025-02-11 13:41 +0100
Message-ID <j5tr7lx1fh.ln2@Telcontar.valinor> (permalink)
References <vof2m0$3d21a$1@paganini.bofh.team>

Show all headers | View raw


On 2025-02-11 09:44, R Daneel Olivaw wrote:
>  From the "man" page:
> 
>> /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 sup-
>>               plied by your system.  By default, searching is case- 
>> sensitive (uppercase  and  lowercase
>>               are  considered  different); the -i option can be used 
>> to change this.  The search starts
>>               at the first line displayed (but see the -a and -j 
>> options, which change this).


And where do you enter that 'N'?
First time I read this.


> I'm running Leap 15.6 (which is where that man page extract came from) 
> and noticed that my searches are case-insensitive.  Of course I do not 
> have -i set but it is possible that OpenSUSE generously sets that option 
> for me via an alias.

Searches have always been case insensitive inside less, for decades (in 
*suse). Since ever. It is the first time I see some one saying they are 
not (the manual).

There are a lot of environment variables mentioned in the manual at the end.

cer@Laicolasse:~> set | grep LESS
LESS='-M -I -R'
LESSCLOSE='lessclose.sh %s %s'
LESSKEY=/etc/lesskey.bin
LESSOPEN='lessopen.sh %s'
LESS_ADVANCED_PREPROCESSOR=no
cer@Laicolasse:~>

There you have.

        -M or --LONG-PROMPT
               Causes less to prompt even more verbose-
               ly than more(1).

        -I or --IGNORE-CASE
               Like  -i,  but searches ignore case even
               if the pattern contains  uppercase  let-
               ters.

        -i or --ignore-case
               Causes searches to ignore case; that is,
               uppercase and lowercase  are  considered
               identical.   This  option  is ignored if
               any  uppercase  letters  appear  in  the
               search  pattern;  in  other  words, if a
               pattern contains uppercase letters, then
               that search does not ignore case.

        -R or --RAW-CONTROL-CHARS
               Like -r, but only  ANSI  "color"  escape
               sequences  and OSC 8 hyperlink sequences
               are output in "raw"  form.   Unlike  -r,
               the screen appearance is maintained cor-
               rectly, provided that there are  no  es-
               cape  sequences  in  the file other than
               these types of escape sequences.   Color
               escape sequences are only supported when
               the color is changed  within  one  line,
               not  across  lines.  In other words, the
               beginning of each line is assumed to  be
               normal  (non-colored), regardless of any
               escape sequences in previous lines.  For
               the  purpose  of keeping track of screen
               appearance, these escape  sequences  are
               assumed to not move the cursor.

               OSC  8  hyperlinks  are sequences of the
               form:

                    ESC ] 8 ; ... \7

               The terminating sequence may be either a
               BEL  character (\7) or the two-character
               sequence "ESC \".

               ANSI  color  escape  sequences  are  se-
               quences of the form:

                    ESC [ ... m

               where  the  "..."  is zero or more color
               specification characters.  You can  make
               less  think  that  characters other than
               "m" can end ANSI color escape  sequences
               by   setting  the  environment  variable
               LESSANSIENDCHARS to the list of  charac-
               ters  which  can  end a color escape se-
               quence.  And you  can  make  less  think
               that  characters other than the standard
               ones may appear between the ESC and  the
               m  by  setting  the environment variable
               LESSANSIMIDCHARS to the list of  charac-
               ters which can appear.

        -r or --raw-control-chars
               Causes  "raw"  control  characters to be
               displayed.  The default  is  to  display
               control characters using the caret nota-
               tion; for example,  a  control-A  (octal
               001) is displayed as "^A" (with some ex-
               ceptions as described under the  -U  op-
               tion).   Warning:  when the -r option is
               used, less cannot keep track of the  ac-
               tual  appearance  of  the  screen (since
               this depends on how the screen  responds
               to  each  type  of  control  character).
               Thus, various display problems  may  re-
               sult,  such as long lines being split in
               the wrong place.

               USE OF THE -r OPTION IS NOT RECOMMENDED.


-- 
Cheers, Carlos.

Back to alt.os.linux.suse | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Text-Searching in "less" R Daneel Olivaw <Danny@hyperspace.vogon.gov> - 2025-02-11 09:44 +0100
  Re: Text-Searching in "less" "Carlos E.R." <robin_listas@es.invalid> - 2025-02-11 13:41 +0100
    Re: Text-Searching in "less" marrgol <marrgol@address.invalid> - 2025-02-11 15:00 +0100
      Re: Text-Searching in "less" "Carlos E.R." <robin_listas@es.invalid> - 2025-02-11 15:12 +0100
    Re: Text-Searching in "less" R Daneel Olivaw <Danny@hyperspace.vogon.gov> - 2025-02-12 18:33 +0100
      Re: Text-Searching in "less" "Carlos E.R." <robin_listas@es.invalid> - 2025-02-12 19:28 +0100
        Re: Text-Searching in "less" mummycullen@gmail-dot-com.no-spam.invalid (MummyChunk) - 2025-02-12 22:40 +0000
          Re: Text-Searching in "less" "Carlos E.R." <robin_listas@es.invalid> - 2025-02-13 00:37 +0100

csiph-web