in reply to reformat log files

Can you show a sample line from the log? If it is just anything followed by a space and the ip, this should be enough:
perl -i~ -pe ' s/(.*) ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) +$/$2 $1/;' 2001-01-02.log
I used the following data for testing:
234.234.234.234.asd.f2.35.346t.sdfg.aws.5332.6t.sdf.as4.23.4234 12.12. +153.43
BTW, this is a shorter version of the regex: s/(.*) ((?:[0-9]{1,3}\.){3}[0-9]{1,3})$/$2 $1/
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: reformat log files
by Anonymous Monk on Aug 31, 2012 at 13:03 UTC
    thank you. That seems to work!