Tinkerweb
Friday, January 6, 2017
Sed on blocks of text
A devops guy just asked me whether sed can work on blocks of text as opposed to just lines. Sure it can. Try this for fun:
man man | sed -rn '/^ *-/{h;:a;n;/^ *$/{bb};s/^ *//g;H;ba;:b;x;s/^ *//g;s/\n/ /g;p}'
Happy to explain how it works. Please note that Mac's sed is broken; please use gsed instead!
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment