如何从 shell 脚本中将结果保存在 excel 中的单独列中?

How to save result in separate column in excel from shell script?

我正在将执行结果保存在 excel sheet 之一中。结果将显示在如下新行中:

我使用了以下命令:

$ bash eg.sh Behatscripts.txt | egrep -w 'Executing the|scenario' >> output.xls

我想显示如下结果:

|                  A                   |          B           |       c     |
1 Executing the script:cap_dutch_home    1 scenario(1passed)
2 Executing the script:cap_english_home  1 scenario(1passed)

另一件事是在执行时会创建 output.xls 单独的文件,而不是使用已经存在的文件。 感谢您的任何建议。

你可以用这个;

用awk;

bash eg.sh Behatscripts.txt | egrep -w 'Executing the|scenario' | awk 'BEGIN {print "Column_A\tColumn_B"}NR%2{printf "%s \t",[=10=];next;}1' output.xls

没有 egrep

bash eg.sh Behatscripts.txt | awk '/Executing the|scenario/' | awk 'BEGIN {print "Column_A\tColumn_B"}NR%2{printf "%s \t",[=11=];next;}1' >> output.xls