将一列分成两行

时间:2015-01-25 14:28:22

标签: bash sorting terminal command line

我有一个包含以下内容的文件:

e1
ed1
e2
ed2
e3
ed3
.
.
.
en
edn

我需要的就是这样:

e1  ed1
e2 ed2
e3 ed3
...
...
...
en edn

我想也许我可以使用grep a并制作包含所有e的单个列文件,并对ed进行相同的操作,然后只需粘贴两列。

但grep会保留文件中的顺序吗? (保证e1将匹配ed2等等)它实际上是大数据,因此无法知道手动验证它

此外,我还不知道正确的语法,到目前为止我所尝试的内容是这样的:

$ grep -o "e" file.txt > thees.txt #this should give me the first column
$ grep -o "ed" file.txt > theeds.txt #this should give me the second column
$ paste thees.txt theeds.txt > bothesandeds.txt #this should join them
$ rm thees.txt
$ rm theeds.txt

我最终得到的是:

e ed
e ed
e ed
...
...
...
e ed

0 个答案:

没有答案