How can I insert newlines in an html file before each table related tag using sed?
A:
This should be a basic solution
sed -s "s/<\(\/\?\)\(t\)/\n<\1\2/gi"
Not 100% perfect as it will ignore col, colgroup and catch the telytype tag but chances are you arn't using either those.
Jeremy French
2009-02-19 13:35:44
+1
A:
sed -e "s/<\\(table\\|td\\|tr\\)/\\ <\\1/gi"
Add other element names you are interested in. Not 100% perfect either: it does not cater for all of HTML weirdness, but then sed will never be enough.
kmkaplan
2009-02-19 13:36:48
Don’t forget the elements THEAD, TBODY, TFOOT, CAPTION, COLGROUP, COL and TH.
Gumbo
2009-02-19 13:45:26
+1
A:
matches opening & closing tags:
sed "s/\(<\/\?\(table\|tr\|td\)\)/\n&/gi"
opening tags only:
sed "s/\(<\(table\|tr\|td\)\)/\n&/gi"
closing tags only:
sed "s/\(<\/\(table\|tr\|td\)\)/\n&/gi"
x-way
2009-02-19 13:45:32