Hirdetés

2024. május 1., szerda

Gyorskeresés

Hozzászólások

(#2497) douggutaby válasza dabadab (#2496) üzenetére


douggutaby
tag

Hibakezelés még kell, de kb ennyi. A sed-del lépegetést lehetett volna szebben is, de nekem jó lesz így is :)
#!/bin/bash

this_date=$1
year=$(date --date="$this_date" "+%Y")
month=$(date --date="$this_date" "+%m" | sed 's/^0*//')
day=$(date --date="$this_date" "+%d" | sed 's/^0*//')
result=""

content=$(curl -s https://www.hrportal.hu/munkaido_${year}.html)
start_num=$(echo "$content" | grep -n "<article>" | cut -d ":" -f 1)
end_num=$(echo "$content" | grep -n "</article>" | cut -d ":" -f 1)

content=$(echo "$content" | sed -n "$start_num,${end_num}p")
month_num=$(echo "$content" | grep -n caltrm | grep -v munkanap | sed "${month}q;d" | cut -d ":" -f 1)
day_type=$(echo "$content" | sed -n "${month_num},\$p" | grep "caltd.*>${day}<" | head -1 | cut -d '"' -f 2)

case "$day_type" in
  caltdb | caltdred | caltdsarga)
    result="hetvege"
    ;;
  caltdszurke | caltd)
    result="munkanap"
    ;;
esac

echo $result

[ Szerkesztve ]

Copyright © 2000-2024 PROHARDVER Informatikai Kft.