一尘不染

使用awk对齐文本文件中的列?

linux

awk被转换成“输入”有用的“所需的输出”?

输入项

testing speed of encryption
test 0 (64 bit key, 16 byte blocks): 2250265 operations in 1 seconds (36004240 bytes)
test 1 (128 bit key, 64 byte blocks): 879149 operations in 1 seconds (56265536 bytes)
test 2 (128 bit key, 256 byte blocks): 258978 operations in 1 seconds (66298368 bytes)
test 3 (128 bit key, 1024 byte blocks): 68218 operations in 1 seconds (69855232 bytes)
test 4 (128 bit key, 8192 byte blocks): 8614 operations in 1 seconds (70565888 bytes)
test 10 (256 bit key, 16 byte blocks): 1790881 operations in 1 seconds (3654096 bytes)

所需的输出

testing speed of encryption
test  0  (64 bit key,   16 byte blocks): 2250265 operations in 1 seconds (36004240 bytes)
test  1 (128 bit key,   64 byte blocks):  879149 operations in 1 seconds (56265536 bytes)
test  2 (128 bit key,  256 byte blocks):  258978 operations in 1 seconds (66298368 bytes)
test  3 (128 bit key, 1024 byte blocks):   68218 operations in 1 seconds (69855232 bytes)
test  4 (128 bit key, 8192 byte blocks):    8614 operations in 1 seconds (70565888 bytes)
test 10 (256 bit key,   16 byte blocks): 1790881 operations in 1 seconds  (3654096 bytes)

阅读 705

收藏
2020-06-07

共1个答案

一尘不染

正确对齐的一个技巧column是使用rev

$ head -1 file; tail -n+2 file | rev | column -t | rev
testing speed of encryption
test   0   (64  bit  key,    16  byte  blocks):  2250265  operations  in  1  seconds  (36004240  bytes)
test   1  (128  bit  key,    64  byte  blocks):   879149  operations  in  1  seconds  (56265536  bytes)
test   2  (128  bit  key,   256  byte  blocks):   258978  operations  in  1  seconds  (66298368  bytes)
test   3  (128  bit  key,  1024  byte  blocks):    68218  operations  in  1  seconds  (69855232  bytes)
test   4  (128  bit  key,  8192  byte  blocks):     8614  operations  in  1  seconds  (70565888  bytes)
test  10  (256  bit  key,    16  byte  blocks):  1790881  operations  in  1  seconds   (3654096  bytes)
2020-06-07