Link to home
Start Free TrialLog in
Avatar of rammaghenthar
rammaghenthar

asked on

how to get all vmstat output file in Excel file (each line in seperate column)

Hi
        I have following script to get vmstat output . I want each column of output in seperate column of Excel file. I have added .xls extension along with output file and checked the file . It was showing each full line per one row which format  I don't need? I think some seperator need to introduce in the script? any help on this please?




Script file
####### cat /backup/vmstat/vmstat_col.ksh
##This is to collect the vmstat output
#/bin/ksh
/usr/bin/vmstat 60 1440 > /backup/vmstat/vmstat.`date +%d`

Cron entry
2 0 * * * /backup/vmstat/vmstat_col.ksh >/dev/null 2>&1

I have attached current output file for reference
vmstat.02.txt
Avatar of farzanj
farzanj
Flag of Canada image

Excel understand CSV format.  You can convert it into CSV format and then excel will be able to open it as per your requirement.

From your file, I can see that it is space delimited.  If you have sed, you can issue command like

sed 's/^  *//;s/  */,/g'  vmstat.02.txt > vmstat.02.csv

Or using perl
perl -pe 's/^\s+//;s/\s+/,/g' vmstat.02.txt > vmstat.02.csv
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rammaghenthar
rammaghenthar

ASKER

Hi Woolmilkporcji,
                 Let me work on it and come back to you