Bash Time Control | Cheatsheet
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 with Sound
seconds=10
while [ $seconds -ge 0 ]; do
echo "Time remaining: $seconds seconds"
seconds=$((seconds-1))
sleep 1
done
echo -e "\a" # Play a system alert sound
echo "Time'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
Rainbow Clock
while true; do
current_time=$(date +"%H:%M:%S")
rainbow_time=$(echo $current_time | awk '{ printf("\033[31m%s \033[32m%s \033[33m%s\033[0m\n", $1, $2, $3) }')
echo "Rainbow Time: $rainbow_time"
sleep 1
done
Morse Code Clock
#!/bin/bash
declare -A morse_code=(
['A']='.-' ['B']='-...' ['C']='-.-.' ['D']='-..' ['E']='.' ['F']='..-.' ['G']='--.' ['H']='....' ['I']='..' ['J']='.---'
['K']='-.-' ['L']='.-..' ['M']='--' ['N']='-.' ['O']='---' ['P']='.--.' ['Q']='--.-' ['R']='.-.' ['S']='...' ['T']='-'
['U']='..-' ['V']='...-' ['W']='.--' ['X']='-..-' ['Y']='-.--' ['Z']='--..' ['0']='-----' ['1']='.----' ['2']='..---' ['3']='...--'
['4']='....-'['5']='.....'['6']='-....'['7']='--...'['8']='---..'['9']='----.' [' ']=' ' ['.']='.-.-.-' [',']='--..--' ['?']='..--..'
['!']='-.-.--'['@']='.--.-.'['#']='-.-.-.'['$']='...-..-'
)
current_time=$(date +"%H:%M:%S")
while true; do
morse_time=""
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
morse_char=${morse_code[$char]}
if [ -n "$morse_char" ]; then
morse_time+=" $morse_char"
fi
done
echo "Morse Code Time: $morse_time"
sleep 1
current_time=$(date +"%H:%M:%S")
done
Hexadecimal Clock
while true; do
current_time=$(date +"%H:%M:%S")
hexadecimal_time=$(echo $current_time | awk -F: '{ printf("%02X:%02X:%02X\n", $1, $2, $3) }')
echo "Hexadecimal Time: $hexadecimal_time"
sleep 1
done
ASCII Art Clock
while true; do
current_time=$(date +"%H:%M:%S")
ascii_time=$(figlet -f standard $current_time)
echo -e "$ascii_time"
sleep 1
clear
done
Digital Art Clock
while true; do
current_time=$(date +"%H:%M:%S")
digital_art_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 "Digital Art Time: $digital_art_time"
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
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
Puzzle Clock
#!/bin/bash
# Define puzzle pieces
piece_1=" -- "
piece_2="| |"
piece_3="|----|"
piece_4=" || "
while true; do
current_time=$(date +"%H:%M:%S")
hour=${current_time:0:2}
minute=${current_time:3:2}
second=${current_time:6:2}
# Clear the screen
clear
# Print the puzzle clock
echo " $piece_1 $piece_1 $piece_1 "
echo " $piece_2 $piece_2 $piece_2 $piece_2 $piece_2 $piece_2 "
echo " $piece_3 $piece_3 $piece_3 $piece_3 $piece_3 $piece_3 "
echo " $piece_2 $hour $piece_2 $piece_2 $minute $piece_2 $piece_2 $second $piece_2 "
echo " $piece_4 $piece_4 $piece_4 $piece_4 $piece_4 $piece_4 "
echo " $piece_1 $piece_1 $piece_1 "
sleep 1
done
Binary Tree Clock
#!/bin/bash
print_tree() {
local depth=$1
local level=$2
if [[ $level -gt 0 ]]; then
for ((i = 0; i < $depth; i++)); do
printf " "
done
for ((j = 0; j < $level; j++)); do
printf
"1 "
done
printf "\n"
print_tree $((depth + 1)) $((level - 1))
print_tree $((depth + 1)) $((level - 1))
fi
}
while true; do
current_time=$(date +"%H:%M:%S")
binary_time=$(echo $current_time | awk -F: '{ printf("%08d:%08d:%08d\n", "0b"$1, "0b"$2, "0b"$3) }')
printf "\n"
print_tree 0 $binary_time
sleep 1
done
Doodle Clock
#!/bin/bash
declare -a pi_digits=(
"3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"
"8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196"
"4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273"
"7245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094"
"3305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912"
"9833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132"
"0005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235"
"4201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859"
"5024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303"
"5982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989"
)
while true; do
current_time=$(date +"%H:%M:%S")
pi_index=$((RANDOM % ${#pi_digits[@]}))
pi_time="${pi_digits[$pi_index]}"
echo "Pi Time: $pi_time"
sleep 1
done
Weather Clock
#!/bin/bash
while true; do
current_time=$(date +"%H:%M:%S")
weather=$(curl -s "wttr.in/?format=%C+%t")
echo "Current Time: $current_time"
echo "Weather: $weather"
sleep 1
clear
done
Countdown to New Year Clock
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)
countdown=$((new_year - current_time))
countdown() {
local duration=$1
while [ $duration -ge 0 ]; do
days=$((duration / 86400))
hours=$((duration % 86400 / 3600))
minutes=$((duration % 3600 / 60))
seconds=$((duration % 60))
printf "Countdown to New Year: %02d days %02d:%02d:%02d\n" $days $hours $minutes $seconds
sleep 1
duration=$((duration - 1))
done
echo "Happy New Year!"
}
countdown $countdown
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
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
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
Morse Code Sound Clock
#!/bin/bash
declare -A morse_code=(
['A']='.-' ['B']='-...' ['C']='-.-.' ['D']='-..' ['E']='.' ['F']='..-.' ['G']='--.' ['H']='....' ['I']='..' ['J']='.---'
['K']='-.-' ['L']='.-..' ['M']='--' ['N']='-.' ['O']='---' ['P']='.--.' ['Q']='--.-' ['R']='.-.' ['S']='...' ['T']='-'
['U']='..-' ['V']='...-' ['W']='.--' ['X']='-..-' ['Y']='-.--' ['Z']='--..' ['0']='-----' ['1']='.----' ['2']='..---' ['3']='...--'
['4']='....-'['5']='.....'['6']='-....'['7']='--...'['8']='---..'['9']='----.' [' ']=' ' ['.']='.-.-.-' [',']='--..--' ['?']='..--..'
['!']='-.-.--'['@']='.--.-.'['#']='-.-.-.'['$']='...-..-'
)
while true; do
current_time=$(date +"%H:%M:%S")
morse_time=""
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
morse_char=${morse_code[$char]}
if [ -n "$morse_char" ]; then
morse_time+=" $morse_char
"
fi
done
echo "Morse Code Time: $morse_time"
sleep 1
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
if [ "$char" == ":" ]; then
sleep 0.3
else
beep -f 800 -l 200 -r 3
fi
sleep 0.1
done
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
Solar System Clock
#!/bin/bash
declare -A planet_positions=(
['☉']='1' ['☿']='2' ['♀']='3' ['♁']='4' ['♂']='5' ['♃']='6' ['♄']='7' ['♅']='8' ['♆']='9' ['♇']='10'
)
while true; do
current_time=$(date +"%H:%M:%S")
solar_system_time=""
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
planet_position=${planet_positions[$char]}
if [ -n "$planet_position" ]; then
solar_system_time+=" $planet_position"
fi
done
echo "Solar System Time: $solar_system_time"
sleep 1
done
Morse Code Light Clock
#!/bin/bash
declare -A morse_code=(
['A']='.-' ['B']='-...' ['C']='-.-.' ['D']='-..' ['E']='.' ['F']='..-.' ['G']='--.' ['H']='....' ['I']='..' ['J']='.---'
['K']='-.-' ['L']='.-..' ['M']='--' ['N']='-.' ['O']='---' ['P']='.--.' ['Q']='--.-' ['R']='.-.' ['S']='...' ['T']='-'
['U']='..-' ['V']='...-' ['W']='.--' ['X']='-..-' ['Y']='-.--' ['Z']='--..' ['0']='-----' ['1']='.----' ['2']='..---' ['3']='...--'
['4']='....-'['5']='.....'['6']='-....'['7']='--...'['8']='---..'['9']='----.' [' ']=' ' ['.']='.-.-.-' [',']='--..--' ['?']='..--..'
['!']='-.-.--'['@']='.--.-.'['#']='-.-.-.'['$']='...-..-'
)
while true; do
current_time=$(date +"%H:%M:%S")
morse_time=""
for ((i = 0;
i < ${#current_time}; i++)); do
char="${current_time:i:1}"
morse_char=${morse_code[$char]}
if [ -n "$morse_char" ]; then
morse_time+=" $morse_char"
fi
done
echo "Morse Code Time: $morse_time"
sleep 1
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
if [ "$char" == ":" ]; then
sleep 0.3
else
sudo sh -c 'echo 1 > /sys/class/leds/led0/brightness'
sleep 0.1
sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'
fi
sleep 0.1
done
done
Geometric Shapes Clock
#!/bin/bash
declare -A shape_codes=(
['☐']='1' ['△']='2' ['◯']='3' ['⬤']='4' ['◆']='5' ['⧇']='6' ['✪']='7' ['❂']='8' ['⚙']='9' ['⧞']='10'
)
while true; do
current_time=$(date +"%H:%M:%S")
shapes_time=""
for ((i = 0; i < ${#current_time}; i++)); do
char="${current_time:i:1}"
shape_code=${shape_codes[$char]}
if [ -n "$shape_code" ]; then
shapes_time+=" $shape_code"
fi
done
echo "Geometric Shapes Time: $shapes_time"
sleep 1
done
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")
timezone_time=$(TZ="Europe/Paris" date +"%H:%M:%S")" (Paris) | "$(TZ="America/New_York" date +"%H:%M:%S")" (NY) | "$(TZ="Asia/Tokyo" date +"%H:%M:%S")" (Tokyo)"
echo "Time Zone Time: $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
3D Clock
#!/bin/bash
while true; do
current_time=$(date +"%H:%M:%S")
echo "3D Time: $current_time"
sleep 1
clear
done