Please consider bottom-posting to lists, and trimming old parts of the reply. Anyone that doesn't have the earlier material can look in the archives. Thanks :-)


On Mon, 23 Aug 2004, Dave Kettmann wrote:

I want this ...:

Aug 23 14:28:32 Auth.notice: (Access-Request 10.10.116.4 166 "000611-011c0c"): Login 
OK [000611-011c0c]

To be this ...:

Aug 23 14:25:32 (Access-Request 10.10.116.4 166 "000611-011c0c"): Login OK

Or to make it easier, I want to take out the 'Auth.notice: ' and anything encased in []'s.

I dont know if im confusing things more, or if I was pointed in the right direction and I just dont understand. Someone please help this poor confused person figure out WTH he is doing wrong :-D

Ok, this is easy to do in Perl, but before providing a sample, please show the list how you would accomplish this using sed. The Perl example will probably be very similar.


Hint: if you can get the string you want to process into $string -- let's assume you have code that somehow gets "Aug 23..." into $string -- then all you need to do is apply the substitutions to that variable:

    $string =~ s/Auth.notice: //;
    $string =~ s/\[[^\]]*\]//;

That appears to work in this contrived example on the command line:

    $ perl -le '$foo = "bl[baz]ooz"; $foo =~ s/\[[^\]]*\]//; print $foo'
    blooz
    $

Which successfully removs the harder of those two patterns.

If this doesn't get you anywhere, please send the list examples of both the Sed and the Perl code that you have tried so far.


-- Chris Devers [EMAIL PROTECTED] http://devers.homeip.net:8080/blog/

np: 'The Twilight Zone Radio Dramas Collection'
     by Rod Serling et al
     from 'The Twilight Zone Radio Dramas Collection'

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to