Re: sed on html pages
Silvio Siefke <[email protected]>
| Newsgroups | gmane.editors.sed.user |
|---|---|
| Message-ID | <[email protected]> |
On Sat, 01 Mar 2014 16:52:11 -0500 Joel Hammer <[email protected]> wrote: > Not sure I understand all you want to do, but, to insert a line break, > this works: > > sed s/target/\n &/ ok that work not so i like, it break </title> but i has now try with <!-- and it works. Hhh funny i swear i search all day break line sed and all what i found not work. hhhh maybe i to stupid for google :) One question i have then im happy. When i delete a html tag, how can i fill the whitespace? Example (tidy clean append id="ext"> <a href="whatever" title="whatever" name="ext" id="ext">whatever</a> i use sed: find -type f -name '*html' -exec sed -i 's!id="ext"!!g' {} \; this come out: <a href="whatever" title="whatever" name="ext" >whatever</a> But can sed clean all so that is not whitespace in it? better come out: <a href="whatever" title="whatever" name="ext">whatever</a> And last question im happy for first use of sed :) Can i combined the follow commands to one sed command: siefke blog $ cat ~/.bin/scripts/webclean #!/bin/bash find -type f -name '*html' -exec tidy -m -config ~/.config/tidy/com {} \; find -type f -name '*html' -exec sed -i '/^$/d' {} \; find -type f -name '*html' -exec sed -i 's|<[/]\?div[^>]*>||g' {} \; find -type f -name '*html' -exec sed -i 's!id="ext"!!g' {} \; find -type f -name '*html' -exec sed -i 's!id="vid"!!g' {} \; find -type f -name '*html' -exec sed -i 's! !!g' {} \; exit Thank you for help & Nice Day Silvio