I have a text file with following content:
...
LogLevelMax=-1
Id=keyboard-setup.service
LogLevelMax=-1
Id= networkd-dispatcher.service
LogLevelMax=-1
Id=systemd-remote-fs.service
LogLevelMax=-1
Id=systemd-journal-flush.service
LogLevelMax=-1
Id=some-other.service
...
I want to save them into an associative array, being key 'Id', value 'LogLevelMax'. Between each "entity" there are exactly 2 new lines. Between LogLevelMax and Id there is exactly one new line.
First, I try to replace 2 empty lines with a character '#':
cat file.txt | tr "\n\n" "#". But it replaces all new lines with '#', not only exactly 2 new lines.
How can I do it in bash with sed, awk, regex or bash functions? Thanks.