Skip to content

Instantly share code, notes, and snippets.

@lafka
Created April 19, 2013 10:28
Show Gist options
  • Save lafka/5419498 to your computer and use it in GitHub Desktop.
Save lafka/5419498 to your computer and use it in GitHub Desktop.
# yes i can do this in sed, why you say? becouse i want to :)
# s/^[^a-z \t].*//;/^$/d # Remove non-parsed lines
# /\[/ { :r # Start loop looking for end ]
# /\]/!N; s/,?\n/,/; tr; # If ending ] is not found, append and repeat
# }
# s/\s+/ /g; # Normalize spaces
# p # Print the pattern space
sed -nE 's/^[^a-z \t].*//;/^$/d; /\[/ { :r; /\]/!N; s/,?\n/,/; tr; }; s/\s+/ /g; p' $conffile
# Will parse:
#dependencies <-
# lager =2.0.0 @github.basho @basho #2.0.0rc1
# tavern @github.lafka
# riak-erlang-client @github.basho @github.lafka [ name = riakc
# version = "1.3.1.1"
# ref = "1.3.1.1" ]
# Into:
# dependencies <-
# lager =2.0.0 @github.basho @basho #2.0.0rc1
# tavern @github.lafka
# riak-erlang-client @github.basho @github.lafka [ name = riakc, version = "1.3.1.1", ref = "1.3.1.1" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment