不同长度的2个未排序文本文件如何可以是由侧显示侧(在列)在一个shell
给定one.txt和two.txt:
$ cat one.txt
apple
pear
longer line than the last two
last line
$ cat two.txt
The quick brown fox..
foo
bar
linux
skipped a line
Run Code Online (Sandbox Code Playgroud)
显示:
apple The quick brown fox..
pear foo
longer line than the last two bar
last line linux
skipped a line
Run Code Online (Sandbox Code Playgroud)
paste one.txt two.txt几乎没有诀窍,但没有很好地对齐列,因为它只是在第1列和第2列之间打印一个选项卡.我知道如何使用emacs和vim,但希望输出显示为stdout用于管道等.
我提出的解决方案使用sdiff然后管道sed删除输出sdiff添加.
sdiff one.txt two.txt | sed -r 's/[<>|]//;s/(\t){3}//'
我可以创建一个函数并将其粘贴在我的.bashrc但是肯定已经存在的命令(或者可能是更清洁的解决方案)?