java - How to break the line before a date pattern using Shell script? -
i have text file that:
13/03/2015 09:21:02 descrição de log (sessão terminada);name.lastname -- 127.0.0.1:66666 -> 0.0.0.0 -- 00:01 -- 13/03/2015 09:21:02 descrição de log (autenticação realizada com sucesso);name.lastname..... i know how can break line every time have date. pattern dd/mm/yyyy. text like:
13/03/2015 09:21:02 descrição de log (sessão terminada);name.lastname -- 127.0.0.1:66666 -> 0.0.0.0 -- 00:01 -- 13/03/2015 09:21:02 descrição de log (autenticação realizada com sucesso);name.lastname..... can me that? can java code, sed, awk, whatever...
thanks.
with gnu sed:
sed -r 's, ([0-9]{2}/[0-9]{2}/[0-9]{4} ),\n\1,g' filename the [0-9]{2}/[0-9]{2}/[0-9]{4} part of regex matches date pattern; whole regex matches surrounded spaces avoid false positives , because example data suggests input meets format. , used separator instead of / in s command because search regex contains slashes.