dotfiles

My configuration files.
Log | Files | Refs | README

commit d97bd2b119b597c4d5f0eee0f025d509f2e166c9
parent c603673aaa3feb6f7c96759b5648e4d1b327f065
Author: Sven Möller <sven@svenmoeller.xyz>
Date:   Sat,  5 Mar 2022 20:58:08 +0100

Modify scripts

Diffstat:
Mbin/.local/bin/newscript | 13++++++++-----
Abin/.local/bin/tanken | 27+++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/bin/.local/bin/newscript b/bin/.local/bin/newscript @@ -1,9 +1,12 @@ #!/bin/sh [ -z "$1" ] && exit 1 -[ -f "$1" ] && echo "File already exists!" && exit 1 -touch "$1" -chmod +x "$1" -printf '#!/bin/sh\n\n\n' > "$1" -vim + $1 +file=~/.dotfiles/bin/.local/bin/$1 + +[ -f "$file" ] && echo "File already exists!" && exit 1 + +touch "$file" +chmod +x "$file" +printf '#!/bin/sh\n\n\n' > "$file" +nvim + $file diff --git a/bin/.local/bin/tanken b/bin/.local/bin/tanken @@ -0,0 +1,27 @@ +#!/bin/sh + +url='https://ich-tanke.de/tankstellen/super-e10/umkreis/36041-fulda/' +dir='/var/www/tanken' + +cd "$dir" + +curl -s "$url" | grep -o '\[{"date.*}\]' | jq -r '.[] | [.date, .close] | @tsv' > "data.tsv.update" +echo "$daily" + +cat data.tsv.update data.tsv | sort -r | uniq > data.tsv.new +mv data.tsv.new data.tsv + +daily="$(cat data.tsv.update | awk -F '\t' '{ sum += $2 }; END { printf("%.2f", sum/NR); }')" +total="$(cat data.tsv | awk -F '\t' '{ sum += $2 }; END { printf("%.2f", sum/NR); }')" +hour="$(grep "$(date +'%H'):00:00" data.tsv | awk -F '\t' '{ sum += $2 }; END { printf("%.2f", sum/NR); }')" + +rm data.tsv.update + +echo "<p><a href=$url>$url</a></p>" > "index.html" +echo "<pre>" >> "index.html" +printf "Durchschnit gesamt:\t$total\n" >> "index.html" +printf "Durchschnit 24h:\t$daily\n" >> "index.html" +printf "Durchschnit Uhrzeit:\t$hour\n" >> "index.html" +echo "" >> "index.html" +cat "data.tsv" >> "index.html" +echo "</pre>" >> "index.html"