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