Skip to content

Bash Time Control | Cheatsheet

A wicked cool cheatsheet for controlling time and mastering various clock functionalities in Bash


QR Code Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  qrencode -t ANSI256 $current_time
  sleep 1
  clear
done

Counter with Delay

counter=0
while true; do
    echo $counter
    counter=$((counter+1))
    sleep 1
done

Countdown Timer

seconds=10
while [ $seconds -ge 0 ]; do
    echo "Time remaining: $seconds seconds"
    seconds=$((seconds-1))
    sleep 1
done
echo "Time's up!"

Countdown Timer

seconds=10
while [ $seconds -ge 0 ]; do
    echo "Time remaining: $seconds seconds"
    seconds=$((seconds-1))
    sleep 1
done
echo "Time's up!"

Countdown Timer (no newlines)

seconds=10
while [ $seconds -ge 0 ]; do
    echo -ne "\rTime remaining: $seconds seconds   "
    seconds=$((seconds-1))
    sleep 1
done
echo -e "\nTime's up!"

Figlet Clock

while true; do
    figlet $(date +"%H:%M:%S")
    sleep 1
    clear
done

Roman Numeral Clock

while true; do
    current_time=$(date +"%H:%M:%S")
    roman_time=$(echo $current_time | awk -F: '{ printf("%02X:%02X:%02X\n", $1, $2, $3) }')
    echo "Roman Time: $roman_time"
    sleep 1
done

Binary Clock

while true; do
    current_time=$(date +"%H:%M:%S")
    binary_time=$(echo $current_time | awk -F: '{ printf("%08d:%08d:%08d\n", $1, $2, $3) }')
    echo "Binary Time: $binary_time"
    sleep 1
done

Wicked Cool Clock

while true; do
    current_time=$(date +"%H:%M:%S")
    wicked_cool_time=$(echo $current_time | sed 's/0/🕛/g; s/1/🕐/g; s/2/🕑/g; s/3/🕒/g; s/4/🕓/g; s/5/🕔/g; s/6/🕕/g; s/7/🕖/g; s/8/🕗/g; s/9/🕘/g')
    echo "Wicked Cool Time: $wicked_cool_time"
    sleep 1
done

Unique Clock

while true; do
    current_time=$(date +"%H:%M:%S")
    unique_time=$(echo $current_time | awk '{ printf("%s%s%s%s:%s%s:%s%s\n", substr($1,2,1), substr($1,1,1), substr($2,2,1), substr($2,1,1), substr($3,2,1), substr($3,1,1), substr($4,2,1), substr($4,1,1)) }')
    echo "Unique Time: $unique_time"
    sleep 1
done

Reverse Clock

while

 true; do
    current_time=$(date +"%H:%M:%S")
    reverse_time=$(echo $current_time | rev)
    echo "Reverse Time: $reverse_time"
    sleep 1
done

Wicked Cool Clock No New Lines

while true; do
    current_time=$(date +"%H:%M:%S")
    wicked_cool_time=$(echo $current_time | sed 's/0/🕛/g; s/1/🕐/g; s/2/🕑/g; s/3/🕒/g; s/4/🕓/g; s/5/🕔/g; s/6/🕕/g; s/7/🕖/g; s/8/🕗/g; s/9/🕘/g')
    echo "Wicked Cool Time: $wicked_cool_time"
    sleep 1
done

Rainbow Clock

colors=(31 32 33 34 35 36 91 92 93 94 95 96)

while true; do
    current_time=$(date +"%H:%M:%S")
    rainbow_time=""

    for ((i=0; i<${#current_time}; i++)); do
        char="${current_time:$i:1}"
        color=${colors[$RANDOM % ${#colors[@]}]}
        rainbow_time+="\033[${color}m${char}\033[0m"
    done

    printf "\rRainbow Time: %b   " "$rainbow_time"
    sleep 1
done

Text Animation Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  for ((i = 0; i < ${#current_time}; i++)); do
    echo -n "${current_time:i:1}"
    sleep 0.5
    echo -ne "\b \b"
    sleep 0.5
  done
  echo ""
done

Matrix Clock

trap 'tput cnorm; tput sgr0; clear; exit' SIGINT

while true; do
  tput civis
  tput clear
  tput cup 0 0

  for ((i = 0; i < 12; i++)); do
    for ((j = 0; j < 12; j++)); do
      rand_num=$((RANDOM % 10))
      echo -n $rand_num
    done
    echo ""
  done

  sleep 0.1
done

Matrix Rain Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  matrix_rain_time=$(echo $current_time | sed 's/\(.\)/\1\n/g')
  echo "Matrix Rain Time:"
  echo "$matrix_rain_time"
  sleep 1
  clear
done

Matrix Clock

#!/bin/bash

trap 'tput cnorm; tput sgr0; clear; exit' SIGINT

while true; do
  tput civis
  tput clear
  tput cup 0 0

  for ((i = 0; i < 12; i++)); do
    for ((j = 0; j < 12; j++)); do
      rand_num=$((RANDOM % 10))
      echo -n $rand_num
    done
    echo ""
  done

  sleep 0.1
done

Matrix Rain Clock Colorless

#!/bin/bash

while true; do
  current_time=$(date +"%H:%M:%S")
  matrix_rain_time=$(echo $current_time | sed 's/\(.\)/\1\n/g')
  echo "Matrix Rain Time:"
  echo "$matrix_rain_time"
  sleep 1
  clear
done

Matrix Rain Clock in Light Green Color

#!/bin/bash

GREEN="\e[92m"
RESET="\e[0m"

while true; do
  current_time=$(date +"%H:%M:%S")

  # Split characters vertically like matrix rain
  matrix_rain_time=$(echo "$current_time" | sed 's/./&\n/g')

  clear
  echo -e "${GREEN}Matrix Rain Time:${RESET}"
  echo -e "${GREEN}${matrix_rain_time}${RESET}"

  sleep 1
done

Emoji Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  emoji_time=$(echo $current_time | sed 's/0/🕛/g; s

/1/🕐/g; s/2/🕑/g; s/3/🕒/g; s/4/🕓/g; s/5/🕔/g; s/6/🕕/g; s/7/🕖/g; s/8/🕗/g; s/9/🕘/g')
  echo "Emoji Time: $emoji_time"
  sleep 1
done

Kaleidoscope Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  kaleidoscope_time=$(echo $current_time | rev)
  echo "Kaleidoscope Time: $kaleidoscope_time"
  sleep 1
done

Text Animation Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  for ((i = 0; i < ${#current_time}; i++)); do
    echo -n "${current_time:i:1}"
    sleep 0.5
    echo -ne "\b \b"
    sleep 0.5
  done
  echo ""
done

Countdown to New Year Clock

#!/bin/bash

current_year=$(date +"%Y")
next_year=$((current_year + 1))
new_year=$(date -d "$next_year-01-01 00:00:00" +%s)
current_time=$(date +%s)
remaining=$((new_year - current_time))

run_countdown() {
  local duration=$1

  while [ $duration -ge 0 ]; do
    days=$((duration / 86400))
    hours=$((duration % 86400 / 3600))
    minutes=$((duration % 3600 / 60))
    seconds=$((duration % 60))

    printf "\rCountdown to New Year: %02d days %02d:%02d:%02d" \
      "$days" "$hours" "$minutes" "$seconds"

    sleep 1
    duration=$((duration - 1))
  done

  printf "\rHappy New Year!                      \n"
}

run_countdown "$remaining"

Count down to christmas

#!/bin/bash

# Get the current date and time
current_date=$(date +"%Y-%m-%d %H:%M:%S")
current_year=$(date +"%Y")

# Calculate the remaining time until Christmas
christmas_date="$current_year-12-25 00:00:00"
remaining_time=$(( $(date -ud "$christmas_date" +%s) - $(date -ud "$current_date" +%s) ))

# Convert the remaining time to months, days, hours, minutes, and seconds
remaining_months=$(( remaining_time / 60 / 60 / 24 / 30 ))
remaining_days=$(( remaining_time / 60 / 60 / 24 % 30 ))
remaining_hours=$(( remaining_time / 60 / 60 % 24 ))
remaining_minutes=$(( remaining_time / 60 % 60 ))
remaining_seconds=$(( remaining_time % 60 ))

# Display the countdown on the same line
while [ $remaining_time -ge 0 ]; do
    echo -ne "Countdown to Christmas: $remaining_months months, $remaining_days days, $remaining_hours hours, $remaining_minutes minutes, $remaining_seconds seconds"\\r
    sleep 1
    remaining_time=$(( remaining_time - 1 ))
    remaining_months=$(( remaining_time / 60 / 60 / 24 / 30 ))
    remaining_days=$(( remaining_time / 60 / 60 / 24 % 30 ))
    remaining_hours=$(( remaining_time / 60 / 60 % 24 ))
    remaining_minutes=$(( remaining_time / 60 % 60 ))
    remaining_seconds=$(( remaining_time % 60 ))
done

echo -e "\nMerry Christmas!"

Starry Night Clock

#!/bin/bash

declare -a stars=(
  "✶" "✷" "✸" "✹" "✺" "✻" "✼" "✽" "✾" "✿" "❀" "❁" "❂" "❃" "❄" "❅" "❆" "❇" "❈" "❉" "❊" "❋" "❄"
)

while true; do
  current_time=$(date +"%H:%M:%S")
  star_index=$((RANDOM % ${#stars[@]}))
  star="${stars[$star_index]}"
  echo "Starry Night Time: $current_time $star"
  sleep 1
done

Starry Night Clock with \r and emojis infront of the Starry word

#!/bin/bash

declare -a stars=(
  "✶" "✷" "✸" "✹" "✺" "✻" "✼" "✽" "✾" "✿"
  "❀" "❁" "❂" "❃" "❄" "❅" "❆" "❇" "❈" "❉"
  "❊" "❋" "❄"
)

while true; do
  current_time=$(date +"%H:%M:%S")
  star="${stars[$RANDOM % ${#stars[@]}]}"

  printf "\r%s Starry Night Time: %s" "$star" "$current_time"

  sleep 1
done

Barcode Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  barcode_time=$(echo $current_time | awk -F: '{ printf("\033[30;47m%s \033[0m\033[47;30m%s \033[0m\033[30;47m%s\033[0m\n", $1, $2, $3) }')
  echo "Barcode Time: $barcode_time"
  sleep 1
done

Typewriter Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  typewriter_time=$(echo $current_time | sed 's/./& /g')
  echo "Typewriter Time: $typewriter_time"
  sleep 1
done

Countdown Clock

countdown() {
  local duration=$1

  while [ $duration -ge 0 ]; do
    minutes=$((duration / 60))
    seconds=$((duration % 60))
    printf "Countdown: %02d:%02d\n" $minutes $seconds
    sleep 1
    duration=$((duration - 1))
  done

  echo "Time's up!"
}

countdown 120

World Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  world_time=$(TZ=America/New_York date +"%H:%M:%S")" (NY) | "$(TZ=Europe/London date +"%H:%M:%S")" (London) | "$(TZ=Asia/Tokyo date +"%H:%M:%S")" (Tokyo)"
  echo "World Time: $world_time"
  sleep 1
done

Time Zone Clock

while true; do
    current_time=$(date +"%H:%M:%S")

    paris=$(TZ="Europe/Paris" date +"%H:%M:%S")
    ny=$(TZ="America/New_York" date +"%H:%M:%S")
    tokyo=$(TZ="Asia/Tokyo" date +"%H:%M:%S")

    timezone_time="Paris: $paris | NY: $ny | Tokyo: $tokyo"

    printf "\rTime Zone Time: %s   " "$timezone_time"
    sleep 1
done

Nixie Tube Clock

while true; do
  current_time=$(date +"%H:%M:%S")
  nixie_time=$(echo $current_time | sed 's/0/𝟘/g; s/1/𝟙/g; s/2/𝟚/g; s/3/𝟛/g; s/4/𝟜/g; s/5/𝟝/g; s/6/𝟞/g; s/7/𝟟/g; s/8/𝟠/g; s/9/𝟡/g')
  echo "Nixie Tube Time: $nixie_time"
  sleep 1
done

Color‑Cycling Gradient Clock

colors=(31 33 32 36 34 35)

shift=0
while true; do
    time=$(date +"%H:%M:%S")
    out=""

    for ((i=0; i<${#time}; i++)); do
        c=${colors[$(( (i+shift) % ${#colors[@]} ))]}
        out+="\033[${c}m${time:$i:1}\033[0m"
    done

    printf "\rGradient Time: %b   " "$out"
    sleep 1
    shift=$((shift+1))
done

Big Digit Clock (No figlet required)

digits=(
"███
█ █
█ █
█ █
███"
" ██
███
 ██
 ██
███"
"███

███

███"
"███

███

███"
"█ █
█ █
███

  █"
"███

███

███"
"███

███
█ █
███"
"███



  █"
"███
█ █
███
█ █
███"
"███
█ █
███

███"
)

while true; do
    t=$(date +"%H%M%S")
    printf "\r"
    for ((row=0; row<5; row++)); do
        line=""
        for ((i=0; i<${#t}; i++)); do
            d=${t:$i:1}
            line+="$(echo "${digits[$d]}" | sed -n "$((row+1))p")  "
        done
        printf "%s\n" "$line"
    done
    sleep 1
    tput cuu 5
done

Emoji Weather Clock

while true; do
    h=$(date +%H)
    case $h in
        05|06|07) icon="🌅";;
        08|09|10|11|12|13|14|15|16) icon="🌞";;
        17|18|19) icon="🌇";;
        *) icon="🌙";;
    esac

    printf "\r$icon  $(date +"%H:%M:%S")   "
    sleep 1
done

Heartbeat clock

while true; do
    t=$(date +"%H:%M:%S")
    printf "\r❤️  %s" "$t"
    sleep 0.3
    printf "\r💖  %s" "$t"
    sleep 0.3
done

Rotating Seperator Clock

rot=( ":" "·" "•" "●" "•" "·" )

i=0
while true; do
    sep=${rot[$i]}
    printf "\r%02d%s%02d%s%02d" \
        "$(date +%H)" "$sep" "$(date +%M)" "$sep" "$(date +%S)"
    sleep 0.2
    i=$(( (i+1) % ${#rot[@]} ))
done
Shadow Clock

while true; do
    t=$(date +"%H:%M:%S")
    printf "\r\033[90m$t\033[0m"
    printf "\033[1D\033[1A"
    printf "\r$t"
    sleep 1
done

Fire Clock

colors=(31 33 91 93)

while true; do
    t=$(date +"%H:%M:%S")
    out=""
    for ((i=0; i<${#t}; i++)); do
        c=${colors[$RANDOM % ${#colors[@]}]}
        out+="\033[${c}m${t:$i:1}\033[0m"
    done
    printf "\r🔥 %b   " "$out"
    sleep 0.2
done

Scrolling Marquee Clock

msg="  $(date +"%H:%M:%S")  "
while true; do
    msg="  $(date +"%H:%M:%S")  "
    for ((i=0; i<${#msg}; i++)); do
        printf "\r%s" "${msg:$i}${msg:0:$i}"
        sleep 0.1
    done
done