[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 Tue 06 Apr 2021 at 09:12:45 (+0000), Curt wrote:
> On 2021-04-06, David Wright <deblis@lionunicorn.co.uk> wrote:
> > On Tue 06 Apr 2021 at 01:09:09 (+0100), jr wrote:
> >> on Mon, 5 Apr 2021 17:44:28 Andrei POPESCU wrote:
> >> > If you are willing to learn (neo)vim, '(n)vim -R' as 'view' can be used
> >> > instead of 'less', with all the power of an advanced editor at your
> >> > disposal.
> >
> > … or '| vim -R -' or even '| vim -' in place of '| less'.
> >
> > But I don't know how vim would do on-the-fly filtering like
> > less can do with & (not being very familiar with vim).
> 
>  :g/pattern/.w! >> output.txt 
> 
> I pressed 'v' in less, searched a pattern and wrote the filtered output
> to a file using the method above. Seemed to work except the results of
> the filtering are not visualized using this method. Of course, you can
> visualize them prior to writing the results to a file (:g/pattern).
> Maybe a little fastidious.

OK, you "pressed 'v' in less", but what was your command line?
Without that, it's difficult to replicate your actions.

> >> or just press 'v' in 'less'?
> >
> > $ sort -m /var/log/kern.log /var/log/user.log | EDITOR=emacs less
> >
> > Pressing v gives me:
> >
> >     Cannot edit standard input  (press RETURN)

Cheers,
David.


Reply to: