2016-08-23 59 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

相關問題