我想根据多个文件中的数据为“玛丽”生成一些摘要统计信息。
input1.txt 看起来像
Jose 88518 95 75 95 62 100 78 68
Alex 97502 84 79 80 73 88 95 79 85 93
Mary 98765 80 75 100 51 83 75 99 50 75 89 94
...
input2.txt 看起来像
Jack 32954 100 98 95 100 93 100 99 98 100 100
Mary 98765 85 83 96 77 81 84 98 75 87
Lisa 83746 100 100 100 100 99 100 98 100 100 100
...
在 Bash 中为 input1.txt 运行以下单行代码:
awk '/Mary/{for(n=3;n<=NF;n++) print $n}' input1.txt | Rscript -e 'summary (as.numeric (readLines ("stdin")))'
结果是:
Min. 1st Qu. Median Mean 3rd Qu. Max.
50.00 75.00 80.00 79.18 91.50 100.00
为 input2.txt 运行以下代码:
awk '/Mary/{for(n=3;n<=NF;n++) print $n}' input2.txt | Rscript -e 'summary (as.numeric (readLines ("stdin")))'
结果是:
Min. 1st Qu. Median Mean 3rd Qu. Max.
75.00 81.00 84.00 85.11 87.00 98.00
如何编写一个单行解决方案,将每个数据文件中的“Mary”统计信息合并到一个报告中,从而产生类似于以下内容的结果?
Min. 1st Qu. Median Mean 3rd Qu. Max.
50.00 75.00 80.00 79.18 91.50 100.00
75.00 81.00 84.00 85.11 87.00 98.00