Bash script read time

You can use the date command to display or set the current date and time. In this tutorial, I will write small program use Bash script read time. Bash script the essential for DevOps Roles.

The syntax of date command

date +"%FORMAT"

Show current time

[huupv@huupv devopsroles]$ date +"%T"

The screen output terminal:

Bash script read time

Set variable _now for the current time

_now=$(date +"%T")
echo "Current time : ${_now}"

The screen output terminal:

Bash script read time 2

Create bash script file

# Display text at given row and column
function show(){
  local x=$1
  local y=$2
  local txt="$3"
  tput cup $x $y
  echo "$txt"
while true
  # Get the system time 12 hour clock time
  now="$(date +"%r")"
  # Show main
  show 11 11 "MAIN MENU for $HOSTNAME - $now"
  show 11 11 "1. System info "
  show 12 11 "2. OS version "
  show 13 11 "3. Exit "
  tput cup 16 11; read -t 2 -p "Choice [1-3] ? " _select
  # do something
  case ${_select} in
    1) read -t 2 -p "Showing system info, wait..." ;;
    2) read -t 2 -p "Showing apache info, wait..." ;;
    3) echo "Bye."; exit 0;;

Run bash script read time

[huupv@huupv devopsroles]$ chmod +x
[huupv@huupv devopsroles]$ ./

Bash script read time 3


Thought the article, you can use Bash script read time. I hope will this your helpful. More details refer to Bash script.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.