Less interrupting in less
I often pipe program output to less, e.g.
produce_output | less
This works great, until produce_output
produces large amounts of output. If I search for some text that is deep into the file, less reports
Calculating line numbers... (interrupt to abort)
If I interrupt with Control+C, it also kills produce_output
, which stops it from producing further output. Is there any way to send the interrupt to less, so that produce_output
keeps running?
I know that I could use kill -INT less_process
, but I think there must be a better solution.
Solution 1:
Normally all processes in a pipeline run in the same process group, causing all of them to receive the signal. You can use setsid foo | less
to run foo
in a different pgrp.
Solution 2:
You can disable line numbers with the
-n or --line-numbers
option.
produce_output | less -n
Solution 3:
You can also just do this:
less +F -f <(produce_output)