Hi,
Please help to seprate my /var/adm/messages output. Than i want to take this
output in the excel.
e,g
cat /var/adm/messages
Sep 4 10:16:52 ibsadm1 inetd[461]: [ID 317013 daemon.notice] vnetd[7032] from 172.17.5.20 38353
Sep 4 10:16:52 ibsadm1 inetd[461]: [ID 317013 daemon.notice] bpcd[7033] from 172.17.5.20 915
Sep 4 10:16:55 ibsadm1 inetd[461]: [ID 317013 daemon.notice] bpcd[7034] from 172.17.5.20 537
so this will be save in some file like this
Date Time Hostname Error mesage
Sep 4 10:16:52 ibsadm1 inetd[461]: [ID 317013 daemon.notice] vnetd[7032] from 172.17.5.20 38353
Than i will copy this output in excel or if there is some process to deport this in excel, Please tell me
Thanks in advance
Regards
Nirjhar
yazu
September 4, 2011, 2:46am
2
Try:
perl -lane 'print "$F[0] $F[1],$F[2],$F[3],@F[4..$#F]"' INPUTFILE >OUTPUT.csv
Hi,
Thanks for the reply but i dont know much about Perl
If possible can you tell me the same in shell scripting.
Regards
Nirjhar
yazu
September 4, 2011, 3:25am
4
There is not a "clean" shell programming/scripting. The shell programming is using and gluing command utilities and here perl is just a command utility like sed, tr, awk, etc...
You can make your csv file with sed or awk but those solutions just would be a little more complex.
Thanks for the reply
From the given code i am not able to see the columns heading
Date Time Hostname Error mesage
The rest i can do with the help of "awk" but i don 't know to get the heading so that my data will come under this.
Regards
Nirjhar
yazu
September 4, 2011, 7:24am
6
(echo 'Date,Time,Hostname,Error Message'; awk '{...}' INPUTFILE) >OUTPUT.csv