Unix & Linux
bash pipe settings shell-builtin
Updated Sun, 28 Aug 2022 10:25:16 GMT

Bash pipe output to more

I am wondering about some bash environment setting here: is it possible to set stdout of bash as a pipe to /bin/more? You know, like using vi as editor for your commands it should be possible to avoid using Ctrl-PgUp or Ctrl-PgDown for looking on all the output (by default).

To be more specific: I don't want to pipe the output of a single command to more like:

$> ls | more
a b c

BUT: pipe any output of my current session to more, so to get either all output printet as usual just beneath the prompt - or if it's too much, screen-wise.

# automatically piped to more:
$> ls 
a b c

Is there any bash-built-in to accomplish this?

EDIT: I wasn't specific enough, sorry for that: I am aware of "script" and command grouping like

(cmdA; cmdB) | less

What I really would like is to automatically avoid getting a 100 page output at once but instead have a more-like behavior of bash'es stdout. As could be accomplished by adding

 2>&1 | more

to all commands entered on command promt - just automatically.


Your question is not specific enough as to what you are trying to achieve. I'll take a few guesses:

If you would like to keep track of anything that happens in a session, use script. See man script for more information.

If you would like to combine the output of multiple commands into one block piped into less use braces like so:

(date; echo; cat /etc/hosts; echo; cat /etc/resolv.conf; echo; host bla.bla) | less

Using more concurrently while typing into the shell won't work as both the shell as well as less will want to read the keyboard from stdin. That's why we have page up and down and search facilities in terminal programs nowadays.

Comments (2)

  • +0 – Hi Coroos, thanks for your quick reply. I am aware of script and command-grouping. What I meant is like adding a ' 2>&1 | more' to the end of each command I enter. — Jun 20, 2013 at 08:41  
  • +0 – Ok, with the comment of Stephane Chazelas I understood your last point - didn't think it through obviously...bash cannot distinguish whether the stdout of a program is applicable for more or whether it is "live" (as vi output) — Jun 20, 2013 at 10:26