我想把一个文件在第n个行之后重新排列成两列。
例如,假设我有一个像这样的文件:
This is a bunch of text that I'd like to print as two columns starting at line number 7 and separated by four spaces. Here are some more lines so I can demonstrate what I'm talking about.
我想将它打印出来,像这样:
This is a bunch and separated by four spaces. of text Here are some that I'd like to print more lines so I can as two demonstrate columns starting what I'm talking about. at line number 7
如何使用bash命令或函数实现呢?
例如,假设我有一个像这样的文件:
This is a bunch of text that I'd like to print as two columns starting at line number 7 and separated by four spaces. Here are some more lines so I can demonstrate what I'm talking about.
我想将它打印出来,像这样:
This is a bunch and separated by four spaces. of text Here are some that I'd like to print more lines so I can as two demonstrate columns starting what I'm talking about. at line number 7
如何使用bash命令或函数实现呢?
while
子进程改写成“map; sort; tail”模型管道,这样可能会更简单。tail
是因为longest
的修改版本在管道创建的子进程中。如果有人对此有强烈的看法,我可以尝试重写它以通过sort -n
而不是操纵临时变量,但我怀疑差异实际上微不足道。 - BRPocock