[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OFF-TOPIC] less with built-in grep ?



In an attempt to save the world from disaster, Ben Pfaff wrote:
>    With the example above, I suppose I could write some kind of macro, opening
>    shell output, but it gets much more interesting when I am looking at
> 
> 	   program | less
> 
>    and I do not want to execute program again, and I also want to be able to go
>    back to un-grepped output without executing program again.
> 
> You can type |grep xxx | less, and this will open a sub-less with the
> grep output in it.  To get back to the ungrepped file, just quit from
> the sub-less.

Interesting. But it doesn't work for me, as my less seems to want
the following syntax (from the man page:)

       | <m> shell-command
              <m> represents any mark letter.  Pipes a section of
              the input file to the  given  shell  command.   The
              section  of  the  file  to  be piped is between the
              first line on the current screen and  the  position
              marked  by  the  letter.  <m> may also be ^ or $ to
              indicate beginning or end of file respectively.  If
              <m> is . or newline, the current screen is piped.

As such, the only way I can do what he wanted is by typing

    g|$grep xxx|less

(where the first "g" shifts less to the top of the file, so that
the "$" results in displaying the wole file. "G|^grep xxx|less" would
have done the trick as well, "!grep xxx %|less", but the latter only
works if the input is a real file) 

Seems rather strange to me that the authors forgot to think of a way to
just tell the "|" command "I want the whole file/input".

$ less -V
less  version 332
$ dpkg -l less
Desired=Unknown/Install/Remove/Purge
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name            Version        Description
+++-===============-==============-============================================
ii  less            332-2          A file pager program, similar to more(1)

-- 
joost witteveen, joostje@debian.org

The upstream maintainer is allowed to do things different 
than Debian, but only if he has good reasons to do so.


--
E-mail the word "unsubscribe" to debian-user-request@lists.debian.org
TO UNSUBSCRIBE FROM THIS MAILING LIST. Trouble?  E-mail to listmaster@debian.org .


Reply to: