Skip to content

Instantly share code, notes, and snippets.

@jamerfort
Created April 20, 2012 20:18
Show Gist options
  • Save jamerfort/2431536 to your computer and use it in GitHub Desktop.
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/)
#!/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