Formatting Shell script output to Excel

I am facing a problem formatting the output of my shell script in excel.
We are directing the output of the script to an excel sheet and need long integer type data printed in Excel as it is (i.e. not in the default scientific notation).
Also, leading zeroes(if any) in the output are getting truncated in the excel file.

For example:

Output of the shell script: 012310004594882
Current output from Excel: 1.231E+13
Desired output in Excel sheet: 012310004594882

Could someone help me with this.
I am using ksh.

This is formatting issue in excel.

Text or number converted to unintended number format in Excel

1 Like

Thanks itkamaraj,

But as I wanted to know if there was a way of doing the formatting using shell script itself rather than manually as described in the link you posted.

The output of my script is directly fed to an excel sheet which gets created each time it is run. We need to ensure that before our data is fed, the excel sheet is already in text mode.We cannot afford to review the data format in excel,as the excel sheet is directly supposed to be attached in an email and sent off.

You could try to enclose that field in double quotes, like "012310004594882" . If that doesn't help, try double quotes PLUS leading apostrophe: "'012310004594882"

It is the default beahaviour of excel. If it exceeds certain digits of number, it will turn the number to scientific notation. You can avoid by choosing the different format.

i guess, you are creating the .csv file and sending in email. One of the way to keep the number, you need to use single quote.