Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c4e27cf

Browse files
author
egberts
committed
Expansion of detailing INI syntax format
1 parent e63e775 commit c4e27cf

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎README.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,49 @@ Treats a no-section (any `keyword=keyvalue` before a `[section]`) as a '`[Defaul
1515

1616
Also correctly finds the last keyvalue of the desired section/keyword before extracting its keyvalue, despite its multiply-defined/multiple-reused interspersed/alternating section blocks.
1717

18+
HOW I DID THIS
19+
==============
20+
21+
The secret sauce is to convert the entire INI file into a parsable syntax format with one `awk`:
22+
23+
```awk
24+
/^\[.*\]$/{obj=0ドル}/=/{print obj 0ドル}'
25+
```
26+
so a bash line was born:
27+
```bash
28+
ini_buffer="$(print "%s" "$raw_buffer" | awk '/^\[.*\]$/{obj=0ドル}/=/{print obj 0ドル}')"
29+
```
30+
31+
Standardized INI Table Format
32+
--------------------------
33+
Next is to standardize the INI to a common syntax format:
34+
```
35+
[section]keyword=keyvale
36+
```
37+
38+
An example INI file might look like this:
39+
```ini
40+
loneSetting=0
41+
42+
[Network]
43+
DNS=1.1.1.1
44+
45+
[Default]
46+
FirstDefaultKeyword=1
47+
48+
```
49+
get turned into this:
50+
```ini
51+
[Default]loneSetting=0
52+
[Network]DNS=1.1.1.1
53+
[Default]FirstDefaultKeyword=1
54+
```
55+
56+
Parsable AWK/SED/GREP Galore!
57+
=======
58+
With a common `[section]keyword=keyvalue`, it now becomes possible to work with INI line-records in a faster manner using `sed`, `awk` and `tail`.
59+
60+
1861
How To Use bash-ini-file
1962
====
2063
Simply source the lone script file: `bash-ini-file.sh`

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /