你可以吗?
awk -F'user' 'NR%2{print $1}' file
举个例子:
kent$ cat file
1.11user 0.00system 0:01.12elapsed 99%CPU (0avgtext+0avgdata 5408maxresident)k
0inputs+0outputs (0major+398minor)pagefaults 0swaps
1.10user 1.00system 0:01.12elapsed 99%CPU (0avgtext+0avgdata 5408maxresident)k
0inputs+0outputs (0major+398minor)pagefaults 0swaps
1.12user 2.00system 0:01.12elapsed 99%CPU (0avgtext+0avgdata 5408maxresident)k
0inputs+0outputs (0major+398minor)pagefaults 0swaps
1.13user 3.00system 0:01.12elapsed 99%CPU (0avgtext+0avgdata 5408maxresident)k
0inputs+0outputs (0major+398minor)pagefaults 0swaps
kent$ awk -F'user' 'NR%2{print $1}' file
1.11
1.10
1.12
1.13
甚至这可能?
awk -F'user' 'NR%2{a[++i]=$1;s+=$1}END{asort(a);print "best: "a[1];print "worst: "a[length(a)];print "avg: "s/length(a)}' file
上面的例子将输出:
best: 1.10
worst: 1.13
avg: 1.115