2016-08-23 56 views
0

我将执行结果保存在excel表格中的一个表格中。结果将会显示在新行象下面这样:如何将结果保存在Excel脚本中的单独列中?

enter image description here

我用下面的命令:

$ 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单独的文件,而不是使用已经存在的文件。 感谢您的任何建议。

回答

1

您可以使用此;

with awk;

bash eg.sh Behatscripts.txt | egrep -w 'Executing the|scenario' | awk 'BEGIN {print "Column_A\tColumn_B"}NR%2{printf "%s \t",$0;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",$0;next;}1' >> output.xls 
+0

感谢您的建议,但其在同一列的 'A' 显示,而不是在下一列 'B'。 – Suraj

+0

@Suraj:我更新了,你可以试试这个。 –

+0

您的解决方案效果很好..需要更多的帮助,请让我知道如果你知道解决方案。我想为列添加标题(标题),有可能吗? – Suraj

相关问题