Created
October 29, 2011 09:49
-
-
Save andrewharvey/1324287 to your computer and use it in GitHub Desktop.
Converts a multi-line formatted SQL query into an escaped single line string for inclusion in a JSON based MML file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Converts a multi-line formatted SQL query into an escaped single line string | |
# for inclusion in a JSON based MML file. | |
# Reads from stdin and writes to stdout. | |
sed '{:q;N;s/\n/\\n/g;t q}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Converts a multi-line formatted SQL query into an escaped single line string | |
# for inclusion in a JSON based MML file. | |
# It also encases the query in "( [query] ) AS [table]" as required for your | |
# MML's table field. | |
# Reads from stdin and writes to stdout. | |
sed '{:q;N;s/\n/\\n /g;t q}' | sed 's/^/(\\n /g' | sed 's/$/\\n) AS /g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Converts a single-line SQL statement from a JSON based MML file into a | |
# multi-line formatted SQL query. | |
# Reads from stdin and writes to stdout. | |
sed 's/\\n/\n/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment