Re: text formatting question

From: Ian Wilson (scobloke2_at_infotop.co.uk)
Date: 03/29/04


Date: Mon, 29 Mar 2004 12:57:49 +0000 (UTC)

cmiller0470@earthlink.net wrote:
> Hello, all.
>
> I've been lurking in this group for some time now, and have picked up
> several helpful pointers from all of you. Thanks for that, and I'm
> hoping you can maybe help me with a question of my own...
>
>
> I have been tasked with taking a system log from one of my applications
> and turning it into a human readable 'daily report,' to be sent out each
> day via a cron job. I have no 'formal' UNIX training, per se, but have
> learned much due to the assumption on the part of my employer that, since
> I know what UNIX is, I must be some sort of guru on the subject.
> Basically, they tossed the baby into the water, and hoped it could swim.
>
> Well... I make no claims to be any sort of olympic athlete, but I
> believe I've at least learned to do the backstroke :-)
>
> Here's my question.
>
> I am using 'grep' and 'grep -v' to filter out the events from the log
> that I am interested in. I am using 'cut' to chop off the nasty bits at
> the beginning and end of each line that I don't want to see. I am using
> 'tr 'xx' 'yy' ' and 'sed s/xx/yy/g' to further make the report more
> readable. Basically, shove it down the pipeline, and trim one bit off at
> a time.
>
> Here's my question:
>
> How the heck do I get the resulting information to line up in nice, neat
> columns, such as a management type would like to see?????
>
>
> Asked here, Hope to see the answer(s) here.

I'd use seomething like:
   fooreport.pl logfile [logfile2 ...] > foo.rep

where fooreport.pl is something like
   #!/usr/bin/perl
   while (<>) { # read lines from log
     next unless /something/; # like grep something
     s/xx/yy/g; # sedlike
     ($this, $that, $other) = split; # not very awklike
     write; # could printf instead
   }
   format STDOUT_TOP=
           THIS THAT
   ------------------- --------------------
   .
   format STDOUT=
   @>>>>>>>>>>>>>>>>>> @<<<<<<<<<<<<<<<<<<<
   $this, $that
   .



Relevant Pages

  • text formatting question
    ... I've been lurking in this group for some time now, ... several helpful pointers from all of you. ... I have no 'formal' UNIX training, per se, but have ... I must be some sort of guru on the subject. ...
    (comp.unix.admin)
  • Re: text formatting question
    ... I have no 'formal' UNIX training, per se, but have ... I make no claims to be any sort of olympic athlete, ... such as a management type would like to see????? ... this looks like the sort of job that perl was made for. ...
    (comp.unix.admin)