Revised sed command line

This commit is contained in:
Shy 2024-08-03 20:55:59 +02:00
parent bdde1235dc
commit 10c627d2ae

8
wled
View file

@ -46,10 +46,10 @@ case "$2" in
l|list)
echo "Presets on $wled_host:"
curl $CURL_FLAGS "http://$wled_host/presets.json" | \
# Split into lines. One line per preset.
sed --sandbox -n 's/"\([0-9]\{1,2\}\)"/\n"\1"/gp' | \
# Extract number and name. Append final newline.
sed --sandbox -n 's/^"\([0-9]\{1,2\}\)":.*"n":"\([[:print:]]*\)".*$/\1: \2/p; a\'
# Split into lines - one line per preset. Append final newline.
sed --sandbox 's/"\(1\?[0-9]\)"/\n"\1"/g; $a\' | \
# Extract number and name of every preset.
sed --sandbox -n 's/^"\(1\?[0-9]\)":.*"n":"\([[:print:]]*\)".*$/\1: \2/p'
exit $?
;;
dump)