My MWE is here
#!/bin/bash
num=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | grep -oE '[0-9]+'|sort -rn|head -n 1)
num=$((num + 1))
echo $num
#gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "[<altered_list>]"
#gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "[$key , $key $num]"
key="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom"
list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
newnum=$(echo "${list}" | grep -oE '[0-9]+' |sort -rn|head -n 1)
echo $newnum
sed -e "/]/${key}${newnum}/" ${list}
#gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "[$key , $key $num]"
echo $key
I want to sed -e "/]/${key}${newnum}/" ${list}
that means from -
['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']
I want to get
['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/','/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/']
add a extra custom3
in the input.