It is possible to print the result of 2 commands side by side...
Something like this
something `ls -l /a` `cat bla.txt`
result:
total 24 #while [ 1 = 1 ]; do
-rw-r--r-- 1 wolfy wolfy 194 Aug 13 08:50 c.in # echo "bla"
-rwxr-xr-x 1 wolfy wolfy 52 Sep 24 11:48 bla.sh #done
-rwxr-xr-x 1 wolfy wolfy 38 Sep 24 11:48 bla1.sh echo "bla"
-rwxr-xr-x 1 wolfy wolfy 147 Sep 24 11:54 ble.sh
I know that pr
can do something like this with files, but I didn't find a way to do this for commands...
You can use process substitution
though in your case, since you have one command and one file:
TL;DR
Consider using a combination of
paste
/column
rather thanpr
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 outputFORMAT:
Detailed Explanation
A highly robust solution is possible through a combination of the
paste
andcolumn
commands.Advantages of the
paste
/column
approach overpr
: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:
Real-life output of
paste
/column
technique on Ubuntu 16.04:See also: combine text files column-wise
For Comparison:
pr
on various platformsTL;DR:
pr
behavior is inconsistent across Linux flavors.Output of
pr
version on Ubuntu:Output of
pr
version on OS X / macOs:Output of
pr
version on Centos:(Surprisingly the behaviour of
pr
under Centos 7 differs from that of all other platforms tested)You can use
screen
like this:In
screen
type Ctrl-a | for vertical and Ctrl-a S for horizontal split.start
ls -l /a
in the right half andcat bla.txt
in the left.