TL; DR
考虑使用paste/ 的组合,column而不是pr获得更一致的结果。
格式:
paste <(cmd1) <(cmd2) | column -s $'\t' -t
详细说明
通过结合使用paste和column命令,可以提供高度可靠的解决方案。
paste/ column方法的优点pr:
具体示例:
paste <(ls -1 .) <(ls -1 ..) | column -s $'\t' -t
paste/ column技术在Ubuntu 16.04上的实际输出:
jay-z@jaytaylor.com:~/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
进行比较:pr在各种平台上
TL; DR: pr行为在各种Linux版本中均不一致。
pr在Ubuntu上版本的输出:
jay-z@jaytaylor.com:~/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
OS X / macOspr上的版本输出:
jay-z@jaytaylor.com:~/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 ...>
Centospr上的version的输出:
(令人惊讶的是,pr在Centos 7下的行为与所测试的所有其他平台的行为不同)
jay-z@jaytaylor.com:~/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 ...>
pr -m一个可以使用paste。