我有一个列文本文件,如下所示:
John
Doe
Male
1984
Marie
Parker
Female
1989
我想把它转换成这样:
John Doe Male 1984
Marie Parker Female 1989
我尝试过使用awk
和modulo,但我无法找到合适的解决方案。
答案 0 :(得分:1)
$ pr -4at file
John Doe Male 1984
Marie Parker Female 1989
或您的格式
$ pr -4ats' ' file
John Doe Male 1984
Marie Parker Female 1989
当然是awk
$ awk 'ORS=NR%4?FS:RS' file
John Doe Male 1984
Marie Parker Female 1989
paste
$ paste -d' ' - - - - < file
John Doe Male 1984
Marie Parker Female 1989