Reformat Java Sql

From EggeWiki
Jump to navigation Jump to search

Occasionally, I come across a large multi-line SQL block inside Java code. The following sed one liner takes the code off from my clipboard, tidies it up, and puts it back in the clipboard.

<geshi lang="bash"> sed -e 's/^[+"[:space:]]*//g; s/[[:space:]+";]*$//g; s:" //: --: < /dev/clipboard > /tmp/$$; cp /tmp/$$ /dev/clipboard; /bin/rm /tmp/$$ </geshi>