我知道如何使用 cut 命令从一行中选择一个字段。例如,给定以下数据:
a,b,c,d,e
f,g,h,i,j
k,l,m,n,o
Run Code Online (Sandbox Code Playgroud)
这个命令:
cut -d, -f2 # returns the second field of the input line
Run Code Online (Sandbox Code Playgroud)
返回:
b
g
l
Run Code Online (Sandbox Code Playgroud)
我的问题:如何选择从末尾开始计数的第二个字段?在前面的示例中,结果将是:
d
i
n
Run Code Online (Sandbox Code Playgroud) 我有一个由 strace 生成的大文本文件,其中简要包含:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
42.93 3.095527 247 12512 unshare
19.64 1.416000 2975 476 access
13.65 0.984000 3046 323 lstat
12.09 0.871552 389 2239 330 futex
11.47 0.827229 77 10680 epoll_wait
0.08 0.005779 66 88 fadvise64
0.06 0.004253 4 1043 193 read
0.06 0.004000 3 1529 3 lstat
0.00 0.000344 0 2254 1761 stat
[...]
0.00 0.000000 0 1 fallocate
0.00 0.000000 0 24 access
0.00 0.000000 0 1 …
Run Code Online (Sandbox Code Playgroud)