Suraj Suraj - 5 months ago 11
Bash Question

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

I am saving the executed result in one of the excel sheet. The result will show in new rows like below:

enter image description here

I have used the below command :

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

I want to display result like below:

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

One more thing is while executing it will create output.xls separate file, instead of using already existed.
Thanks for any suggestions.


You can use this;

with awk;

bash Behatscripts.txt | egrep -w 'Executing the|scenario' | awk 'NR%2{printf "%s \t",$0;next;}1' >> output.xls

without egrep

bash Behatscripts.txt | awk '/Executing the|scenario/' | awk 'NR%2{printf "%s \t",$0;next;}1' >> output.xls