Hi i have a log file
P12345_15728710[01/03/2013 18:16:35]:DEBUG:Begin
P12345_15728710[01/03/2013 18:16:35]:DEBUG:Being
P12345_15729310[01/03/2013 18:48:35]:DEBUG:GetAgen
P12345_15726510[01/03/2013 18:49:35]:DEBUG:end
i want to trim this file and i want like this
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15729310[01/03/2013 18:48:35]
15726510[01/03/2013 18:49:35]
i tried sed ..but not working..
sed "s/.*P12345__ \(.*\) :DEBUG*/\1/"
sed 's/.*_//;s/].*/]/' myFile
1 Like
Jotne
3
awk -F"_|:D" '{print $2}' infile
---------- Post updated at 14:02 ---------- Previous update was at 13:57 ----------
awk '{print substr($0,8,29)}' infile
Also a small additional modifiaction ..in the below output
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:16:35]
15728710[01/03/2013 18:48:35]
15729310[01/03/2013 18:48:35]
15729310[01/03/2013 18:48:35]
15729310[01/03/2013 18:48:35]
15729310[01/03/2013 18:50:35]
15726510[01/03/2013 18:49:35]
15726510[01/03/2013 18:49:35]
15726510[01/03/2013 18:49:35]
15726510[01/03/2013 18:50:35]
15726510[01/03/2013 18:53:35]
i want to select unique data with start and stop time stamp
i.e
15728710 [01/03/2013 18:16:35]-[01/03/2013 18:48:35]
15729310[01/03/2013 18:48:35]-[01/03/2013 18:50:35]
15726510[01/03/2013 18:49:35]-[01/03/2013 18:53:35]
---------- Post updated at 09:00 PM ---------- Previous update was at 12:36 AM ----------
please atleast provide some logic so that i can try...
RudiC
5
Try
$ awk -F[]_[] '$2!=p {if (NR>1) printf "[%s]\n", d; printf "%s[%s]-", $2,$3;p=$2}
{d=$3}
END {printf "[%s]\n", d}
' file
15728710[01/03/2013 18:16:35]-[01/03/2013 18:48:35]
15729310[01/03/2013 18:48:35]-[01/03/2013 18:50:35]
15726510[01/03/2013 18:49:35]-[01/03/2013 18:53:35]