regex - Auto-clean Log Formats -
i've run several different situations need implement "log cleanup" regex. i've had re-implement couple times, basic variant this:
the original
(23:59:59) username says: user inputted text (00:00:13) username user inputted action (00:01:42) username says: user inputted text (00:02:13) username says: user inputted text
i'm looking lookahead/lookbehind regex converts to:
(23:59:59) username says: user inputted text (00:00:13) username user inputted action (00:01:42) username says: user inputted text (00:02:13) username says: user inputted text
what's angle of attack, , why?
unless regex absolutely necessary,
awk '/^\(/{print ""}{printf "%s ",$0}' file
the logic behind print lines without newline, except when "(" encountered first character. can implemented in language.
bash
#!/bin/bash while read -r line case "$line" in "("* ) echo esac printf "%s " $line done<"file"
Comments
Post a Comment