From 57892c86a12f094afcda44ac09b4b942ce7f648b Mon Sep 17 00:00:00 2001 From: Dominika Liberda Date: Mon, 30 Aug 2021 20:57:54 +0000 Subject: [PATCH] * fixes number formating without coreutils --- webroot/watch.shs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/webroot/watch.shs b/webroot/watch.shs index 1335ced..cefa792 100755 --- a/webroot/watch.shs +++ b/webroot/watch.shs @@ -1,5 +1,9 @@ #!/bin/bash +function format_numbers() { + rev | sed "s#[[:digit:]]\{3\}#&,#g" | rev | sed -E 's/^,//' +} + if [[ ! -d "temp" ]]; then mkdir "temp" fi @@ -119,9 +123,9 @@ if [[ "${get_data[v]}" ]]; then fi strings[upload_date]=$(date -d "$(echo $video | jq -r '.upload_date' | sed -E 's/..../&-/;s/....-../&-/')" "+%d %B %Y") - strings[view_count]=$(echo $video | jq -r '.view_count' | xargs printf "%'d\n") - like_count=$(echo $video | jq -r '.like_count' | xargs printf "%'d\n") - dislike_count=$(echo $video | jq -r '.dislike_count' | xargs printf "%'d\n") + strings[view_count]=$(echo $video | jq -r '.view_count' | format_numbers) + like_count=$(echo $video | jq -r '.like_count' | format_numbers) + dislike_count=$(echo $video | jq -r '.dislike_count' | format_numbers) if [[ ${cfg[template]} == 'default' ]]; then if [[ $like_count == 'null' && $dislike_count == 'null' ]]; then strings[like_dislike_count]="Likes are turned off"