Skip to content

Instantly share code, notes, and snippets.

@OBdA
Created June 26, 2012 13:15
Show Gist options
  • Save OBdA/2995730 to your computer and use it in GitHub Desktop.
Save OBdA/2995730 to your computer and use it in GitHub Desktop.
sed: collapse logical lines
#! /bin/sed -f
# SED script to concatenate logical lines sepaated by
# backslashes (\) at the end of the "physical" line
# set branch target 't'
:t
# apply the following on all lines ending with an '\'
/\\$/ {
# concatenate actual line with the next in pattern space
N;
# replace '\<newline' with nothing
s/\\\n//;
# branch to label 't' and go on...
bt;
}
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment