Created
April 20, 2012 20:18
-
-
Save jamerfort/2431536 to your computer and use it in GitHub Desktop.
Pull queries from the logs of Oracle imp utility. (http://iggyfernandez.wordpress.com/2012/04/20/i-sed-awk/)
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
#!/usr/bin/sed -n -f | |
# Usage: sed -n -f <THISFILE> <IMP_LOG_FILE> | |
# run these commands for any line that starts with a space | |
/^ /{ | |
# replace the leading space | |
s/^ // | |
# define a label | |
:getnewline | |
# get the next line into the pattern space | |
N | |
# try to replace the newline and leading space of the line we just added | |
s/\n // | |
# if the previous replacement worked, jump back to the "getnewline" label | |
t getnewline | |
# after we get here, we either added a line that didn't start with a leading space, or we are at the end of the file | |
# try to remove the last line we added, if it didn't start with a leading space. | |
s/\n.*$// | |
# replace the quotes | |
s/"//g | |
# print the pattern space | |
p | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment