Reformat Java Sql

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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>