Created
February 7, 2020 16:36
-
-
Save double16/f8e532076812f0ba30661b839a242808 to your computer and use it in GitHub Desktop.
ini.sed
This file contains hidden or 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
# this will convert the ini data into this flat format: | |
# | |
# owner|name|John Doe | |
# owner|organization|Acme Widgets Inc. | |
# database|server|192.0.2.62 | |
# database|port|143 | |
# database|file|payroll.dat | |
# Configuration bindings found outside any section are given to | |
# to the default section. | |
1 { | |
x | |
s/^/default/ | |
x | |
} | |
# Lines starting with a #-character are comments. | |
/#/n | |
# Sections are unpacked and stored in the hold space. | |
/\[/ { | |
s/\[\(.*\)\]/\1/ | |
x | |
b | |
} | |
# Bindings are unpacked and decorated with the section | |
# they belong to, before being printed. | |
/=/ { | |
s/^[[:space:]]*// | |
s/[[:space:]]*=[[:space:]]*/|/ | |
G | |
s/\(.*\)\n\(.*\)/\2|\1/ | |
p | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment