我正在编写一个 bash 脚本,我试图首先删除最后三行,然后将其解析为 excel 格式的文件,以便能够制作图表。
这是我运行的命令:
./a.out | tail -7
输出
Copy: 3374.3 0.047656 0.047417 0.047898
Scale: 3337.4 0.048221 0.047942 0.048456
Add: 3616.4 0.066834 0.066364 0.067662
Triad: 3597.4 0.067162 0.066715 0.067727
-------------------------------------------------------------
Solution Validates: avg error less than 1.000000e-13 on all three arrays
-------------------------------------------------------------
我的问题:
- 如何删除最后三行?
- 如何将数据解析为 excel 文件以制作图表?
最佳答案
How can I remove the three last lines ?
head -n-3 myfile.txt
How can I parse the data into a excel file to make graphs?
awk '{printf("%s,%s,%s,%s,%s", $1, $2, $3, $4)}' myfile.txt
因此,如果将它们结合起来,您的命令将是:
head -n-3 myfile.txt | awk '{printf("%s,%s,%s,%s,%s", $1, $2, $3, $4)}'
关于linux - 将数据解析为 CSV 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33721654/