32

I have a command which outputs lots of data (say, strace with lots of syscalls, running for a few minutes).

Is there any option (e.g. command wrapper or something similar) that would allow me to pause the output of the command (just the output on the screen, I don't mind the command running in the background), then unpause it after I take a look on its output?

3 Answers 3

50

You have three options:

  • press controlS to stop output, controlQ to resume (this is called XON/XOFF)
  • redirect your output to a pager such as less, e.g., strace date | less
  • redirect your output to a file, e.g., strace -o foo date, and browse it later.
2
  • 8
    Note that stopping the output with either of the two first options here will make the data generating program pause too, while it waits for the output stream to be consumed.
    – Kusalananda
    Commented Jul 8, 2016 at 11:25
  • ....and you don't need to wait till "later" to see the output from option 3. e.g. You can watch it in realtime with tail -f in a separate session/window.
    – symcbean
    Commented Aug 19 at 14:45
2

use the | pipe for example

ifconfig -a | more

this will list until screen is full and one can then scroll further by hitting return / enter.

2
  • 1
    I prefer this to less because it exits naturally. Commented Mar 31, 2020 at 3:13
  • But isn't that more or less the same? ;)
    – JamesR404
    Commented Aug 4, 2022 at 13:38
1

You can use tee to log all outputs in a file and as well as show in console. This doesn't pause the program like XON/XOFF flow controls or less (as pausing may cause issue in program like timeout)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .