两个不同长度的未排序文本文件如何在 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
Display:
apple The quick brown fox..
pear foo
longer line than the last two bar
last line linux
skipped a line
paste one.txt two.txt
几乎可以做到这一点,但是不能很好地对齐列,因为它只在列1和列2之间打印一个选项卡。我知道如何与 emacs 和 vim,但要输出显示为标准输出管道等。
我想出的解决方案使用 sdiff
,然后通过管道 sed 删除输出 sdiff
添加。
sdiff one.txt two.txt | sed -r 's/[<>|]//;s/(\t){3}//'
I could create a function and stick it in my .bashrc
but surely a command for this exists already (or a 清洁工 solution potentially)?