Suraj Suraj - 1 year ago 69
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.

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download