Re: [dev] ii: how to process out in a pipeline and still page with more
May 27, 2022, 11:43 AM, "Greg Reagle" <list_AT_speedpost.net mailto:list_AT_speedpost.net?to=%22Greg%20Reagle%22%20%3Clist%40speedpost.net%3E > wrote:
>
> I have a file named "out" (from ii) that I want to view. Of course, it can grow while I am viewing it. I can view it with "tail -f out" or "less +F out", both of which work. I also want to apply some processing in a pipeline, something like "tail -f out | tr a A | more" but that does not work. The more command ignores my keystrokes (unless I hit Ctrl-Java 7, but that kills tail and tr). The "tr a A" command is arbitrary; you can substitute whatever processing you want, even just cat.
>
> This command "tail -f out | tr a A" is functional and has no bugs, but it doesn't let me use the power of more, which I crave.
>
> This command "tail out | tr a A | more" is functional and has no bugs, but it doesn't let me see newly appended lines.
>
> Can I use the power of the Unix pipeline to do text processing and the power of more for excellent paging and still be able to see new lines as they are appended? Why doesn't or can't more continue to monitor stdin from the pipeline and respond to my keystrokes from the tty?
>
> I am using Debian 11 in case it matters, with fish. But I am happy to try other shells. In fact I already have and that doesn't seem to help. I have also tried less, least, nano -, and vi -, instead of more, to no avail.
>
Hi Greg,
Why don't you just save the output to the temporary file after your processing? Like
```
tail -f out | tr a A > out.post &
less +F out.post
```
If you ran something like this in a script, you may want to ensure everything gets cleaned up when it exists.
Another option is to use vi/vim and have it periodically reload the file.
>Why doesn't or can't more continue to monitor stdin from the pipeline and respond to my keystrokes from the tty?
Probably because more doesn't know it should check a tty. Programs like more often check to see if stdin refers to a tty and in the pipeline above, more's stdin isn't a tty. See `echo | tty` vs `tty`. You may be able to modify more to check to see if stdout/stderr refers to a tty instead.
Arthur
Received on Fri May 27 2022 - 23:32:57 CEST
This archive was generated by hypermail 2.3.0
: Fri May 27 2022 - 23:36:08 CEST