I'm gluing together a small block of bash code that would parse the output of gsettings get command.
I'm not sure what's wrong here.
This is the example of input. (gsettings get org.gnome.desktop.input-sources sources)
This is the code that parses the input
Expected output:
The output I've got:
I'm not sure what's wrong here.
This is the example of input. (gsettings get org.gnome.desktop.input-sources sources)
Code:
[('xkb', 'us'), ('xkb', 'lt')]
This is the code that parses the input
Bash:
#!/bin/bash
TEXT_TO_PARSE=$(gsettings get org.gnome.desktop.input-sources sources)
REGEX_PATTERN="\((.*?)\)"
while [[ ${TEXT_TO_PARSE} =~ (${REGEX_PATTERN}) ]]; do
echo "${BASH_REMATCH[1]}"
TEXT_TO_PARSE=${TEXT_TO_PARSE##*${BASH_REMATCH[1]}}
done
Expected output:
Code:
('xkb', 'us')
('xkb', 'lt')
The output I've got:
Code:
('xkb', 'us'), ('xkb', 'lt')