• Dein Produkt auf beyond.lol
  • Kontakt
  • Kontakt
  • IP
  • Impressum
  • Datenschutz
  • Software
    • Open Source
  • Hardware
  • Tutorials
    • Web
    • Linux
    • Windows
    • Gaming
    • PHP
    • Raspberry Pi
  • Crypto-Welt
    • Altcoins
    • Bitcoin
    • Ethereum
    • Mining
  • Scripts
    • BASH
    • PowerShell
  • Lustiges aus der IT
    • Spamantworten
  • Gaming
  • and More
    • Dein Produkt auf beyond.lol
    • Kontakt
    • Impressum
    • Datenschutz
    • Tools
      • Wie ist meine IP?
No Result
View All Result
  • Software
    • Open Source
  • Hardware
  • Tutorials
    • Web
    • Linux
    • Windows
    • Gaming
    • PHP
    • Raspberry Pi
  • Crypto-Welt
    • Altcoins
    • Bitcoin
    • Ethereum
    • Mining
  • Scripts
    • BASH
    • PowerShell
  • Lustiges aus der IT
    • Spamantworten
  • Gaming
  • and More
    • Dein Produkt auf beyond.lol
    • Kontakt
    • Impressum
    • Datenschutz
    • Tools
      • Wie ist meine IP?
No Result
View All Result
No Result
View All Result
Home Scripts BASH

BASH Countdown bis Weihnachten

Patrick by Patrick
Dezember 19, 2022
in BASH, Scripts
5
0
Automatisches Update von Ubuntu aktivieren
0
SHARES
49
VIEWS
Auf Facebook teilenAuf Twitter teilenAuf Whatsapp teilen

Ein BASH Skript, welches einen Countdown bis Weihnachten anzeigt. Kann natürlich auch für andere Tage benutzt werden.

#!/bin/bash

# Set the target date (Christmas)
target_month=12
target_day=25

# Get the current date
current_month=$(date +%m)
current_day=$(date +%d)

# Calculate the number of days until Christmas
if [ $current_month -gt $target_month ] || [ $current_month -eq $target_month -a $current_day -ge $target_day ]
then
  # Christmas has already passed this year, so set the target date to next year
  target_year=$(date +%Y)
  let "target_year+=1"
else
  # Christmas has not passed yet this year
  target_year=$(date +%Y)
fi

# Calculate the number of seconds until Christmas
target_date="$target_year-$target_month-$target_day 00:00:00"
seconds_until_christmas=$(date -d "$target_date" +%s)
current_time=$(date +%s)
let "seconds_until_christmas-=current_time"

# Calculate the number of days, hours, minutes, and seconds until Christmas
days=$((seconds_until_christmas / 86400))
hours=$((seconds_until_christmas % 86400 / 3600))
minutes=$((seconds_until_christmas % 3600 / 60))
seconds=$((seconds_until_christmas % 60))

# Print the countdown message
echo "There are $days days, $hours hours, $minutes minutes, and $seconds seconds until Christmas!"

Das Skript setzt das Ziel-Datum (Weihnachten) auf den 25. Dezember und berechnet dann die Anzahl der Tage, Stunden, Minuten und Sekunden bis zu diesem Datum. Wenn das aktuelle Datum nach dem Ziel-Datum liegt, wird das Ziel-Jahr um 1 erhöht, um den Countdown für das nächste Jahr zu berechnen.

Um das Skript auszuführen, speichere es zunächst in einer Datei mit einem beliebigen Namen und fügen Sie ihm dann Ausführungsberechtigungen hinzu:

chmod +x countdown.sh

Danach kannst du das Skript ausführen

./countdown.sh
Tags: bashcountdownweihnachten
Previous Post

PowerShell Uhrzeit mit NTP synchronisieren

Next Post

BASH Aktienkurs mit der Yahoo Finance API anzeigen

Patrick

Patrick

IT Systemadministrator

Next Post
Automatisches Update von Ubuntu aktivieren

BASH Aktienkurs mit der Yahoo Finance API anzeigen

Schreibe einen Kommentar Antwort abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Bloggerei.de - Bewertung für beyond.lol
  • Dein Produkt auf beyond.lol
  • Kontakt
  • Kontakt
  • IP
  • Impressum
  • Datenschutz

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist

No Result
View All Result
  • Software
    • Open Source
  • Hardware
  • Tutorials
    • Web
    • Linux
    • Windows
    • Gaming
    • PHP
    • Raspberry Pi
  • Crypto-Welt
    • Altcoins
    • Bitcoin
    • Ethereum
    • Mining
  • Scripts
    • BASH
    • PowerShell
  • Lustiges aus der IT
    • Spamantworten
  • Gaming
  • and More
    • Dein Produkt auf beyond.lol
    • Kontakt
    • Impressum
    • Datenschutz
    • Tools
      • Wie ist meine IP?

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.