How to extract output from a script to .xls file

Hi,

I am running a script, the output of which is needed to be filled in .xls file. I am doing this manually now, i mean I am writing the output of the script to Excel file manually. How to redirect the output of the script to .xls file? Please help me out!!!

Thanks much,
Scriptlearner.

You can just format your output such that the values of the output are delimited to "," and are redirected to a CSV file.

So you can use to CSV file to view your output in the excel format

You mean you are copying outputs from the screen to an excel file?

You can format your outputs in CSV format (like lorcan suggested) and redirect the script out to a file say,

$ sh your_script.sh > your_output.csv

does that help?

Hi,

Thanks a lot. Yep,it works if I am extracting output from .sh file. Actually I have one shell script i.e myscripts.sh, in which it calls other .sql scripts which are in my home directory. Actually I wanted the output of .sql scripts to .csv file. I tried to get the output of .sql to .csv, but it is throwing error. Can I redirect the output from myscripts.sh to myouput.csv?Is that possible? Please help me.

Thanks much in advance,
Scriptlearner.

You cannot redirect the SQL queries to the files. Instead you can use the spool concept in ORACLE (hope Oracle is the database).

Spool your output such that the records are comma separated.

something like the below;

select sysdate||","|| sysdate from dual;
spool on;
/
spool off;

This will have the output from the sql command into the Spool file.

Thanks a lot for your help. I got that. Initially I got problem coz my.sql script had control characters in it. Now it is working fine.

Thanks a lot,
Scriptlearner.

If you want redirect the output file to .xls file from your script. you can use the following command,

$ shell_script.ksh > test.xls

Regards,
Siva.P
Bangalore