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

Re: How to save filtered less results in a file or on stdout



On Sun 28 Mar 2021 at 20:38:08 (+0200), l0f4r0@tuta.io wrote:
> 
> Strictly speaking, my question is not on Debian itself, but on usage of less command running on my Buster (487-0.1+b1).
> 
> Is there a way to save *filtered* less results in a file or on stdout please?
> 
> What I mean by "filtered" is results obtained via "&" or "&!" command inside less.
> 
> Indeed, commands like "|", "-o" or "s" inside less don't seem to take filtering into account...

When you've used
  & pattern
to display lines containing your pattern, then
  | . grep pattern > filename
will apply the same filter to the lines selected by | ., where
I've used . but you could use ^ or $ or a mark instead, as
appropriate.

Cheers,
David.


Reply to: