in reply to Getting my username from log
This works with the data you provided:
#!/usr/bin/env perl use 5.010; use strict; use warnings; my $re = qr{ user= [<"]? ( \S+? ) [>"]? ,? \s }x; while (<DATA>) { /$re/; say $1; } __DATA__ .... user=jtkirk, ip=[::ffff:127.0.0.1], top=0,.... .... user=<jtkirk@enterprise.com>, ip=[::ffff:127.0.0.1], top=0,.... .... user="jtkirk@enterprise.com" passwd="XXXXXX"....
Output:
$ pm_log_uname_regex.pl jtkirk jtkirk@enterprise.com jtkirk@enterprise.com
-- Ken
|
|---|