Date: July 23, 2024 - 07:58 AM - 175.139.235.17 xev wrote:
#!/bin/bash
# Path to the file containing prayer time table time_table_file="prayer_times.txt"
# Get current date and time current_date=$(date +%Y%m%d) current_time=$(date +%H:%M)
# Adjusted time for the third column adjusted_time=$(date -d "$current_time + 28 minutes" +%H:%M)
# Find matching time in the table and alert if found while read -r line; do # Extract date and times from the line table_date=$(echo "$line" | awk '{print $1}') time1=$(echo "$line" | awk '{print $2}') time2=$(echo "$line" | awk '{print $3}') time3=$(echo "$line" | awk '{print $4}') time4=$(echo "$line" | awk '{print $5}') time5=$(echo "$line" | awk '{print $6}') time6=$(echo "$line" | awk '{print $7}')
# Check if the line's date matches today's date if [[ "$table_date" == "$current_date" ]]; then # Compare current time with each time in the table if [[ "$time1" == "$current_time" ]]; then echo "It's time!" fi if [[ "$time2" == "$current_time" ]]; then echo "It's time!" fi # Adjusted time for the third column if [[ "$time3" == "$adjusted_time" ]]; then echo "It's time!" fi if [[ "$time4" == "$current_time" ]]; then echo "It's time!" fi if [[ "$time5" == "$current_time" ]]; then echo "It's time!" fi if [[ "$time6" == "$current_time" ]]; then echo "It's time!" fi fi done < "$time_table_file"