Print command result side by side
You can use process substitution
pr -m <(cmd1) <(cmd2)
though in your case, since you have one command and one file:
ls -l | pr -m - bla.txt
TL;DR
Consider using a combination of paste
/ column
rather than pr
to get more consistent results.
Depending on your OS,
pr
incorrectly mixes in the columns when input lengths differ (Ubuntu, macOS) or even worse will print each input on a completely different pages (Centos 7)pr
both prepends and appends extraneous output
FORMAT:
paste <(cmd1) <(cmd2) | column -s $'\t' -t
Detailed Explanation
A highly robust solution is possible through a combination of the paste
and column
commands.
Advantages of the paste
/ column
approach over pr
:
Cleaner output due to no timestamp or page header information being prepended, nor a full screen of empty lines appended
Columns always stay separate even when the input lengths are different
Concrete example:
paste <(ls -1 .) <(ls -1 ..) | column -s $'\t' -t
Real-life output of paste
/ column
technique on Ubuntu 16.04:
[email protected]:~/go/src/github.com/jaytaylor/html2text
$ paste <(ls -1 .) <(ls -1 ..) | column -s $'\t' -t
LICENSE archiveify
README.md go-hostsfile
html2text.go html2text
html2text_test.go jaytaylor
testdata mockery-example
shipbuilder
stoppableListener
tesseract-web
See also: combine text files column-wise
For Comparison: pr
on various platforms
TL;DR: pr
behavior is inconsistent across Linux flavors.
Output of pr
version on Ubuntu:
[email protected]:~/go/src/github.com/jaytaylor/html2text
$ pr -m <(ls -1 .) <(ls -1 ..)
2017-05-25 15:50 /dev/fd/62 Page 1
LICENSE archiveify
README.md go-hostsfile
html2text.go html2text
html2text_test.go jaytaylor
testdata mockery-example
shipbuilder
stoppableListener
tesseract-web
Output of pr
version on OS X / macOs:
[email protected]:~/go/src/github.com/jaytaylor/html2text
$ pr -m <(ls -1 .) <(ls -1 ..)
May 25 08:55 2017 Page 1
LICENSE archiveify
README.md go-hostsfile
html2text.go html2text
html2text_test.go jaytaylor
testdata mockery-example
shipbuilder
stoppableListener
tesseract-web
<... remainder of screen filled with blank lines ...>
Output of pr
version on Centos:
(Surprisingly the behaviour of pr
under Centos 7 differs from that of all other platforms tested)
[email protected]:~/go/src/github.com/jaytaylor/html2text
$ pr <(ls -1 .) <(ls -1 ..)
2017-05-25 15:59 /dev/fd/63 Page 1
LICENSE
README.md
html2text.go
html2text_test.go
testdata
<... remainder of screen filled with blank lines ...>
2017-05-25 16:21 /dev/fd/62 Page 1
archiveify
go-hostsfile
html2text
jaytaylor
mockery-example
shipbuilder
stoppableListener
tesseract-web
<... remainder of screen filled with blank lines ...>