date command in unix
#Write a script to display the date, time and a welcome message (like Good Morning etc.). The time should be displayed with “a.m.” or “p.m.” and not in 24 hours notation.
currentHour=`date +%H`
currentTime=`date +"%I : %M : %S %p"`
if [ $currentHour -lt 12 ]
then
msg="Good Morning"
elif [ $currentHour -ge 12 ] && [ $currentHour -lt 16 ]
then
msg="Good Afternoon"
elif [ $currentHour -ge 16 ] && [ $currentHour -lt 21 ]
then
msg="Good Evening"
else
msg="Good Night"
fi
#format of time [ HH : MM : SS : AM/PM]
echo "$msg ,\nCurrent Time is $currentTime"
currentHour=`date +%H`
currentTime=`date +"%I : %M : %S %p"`
if [ $currentHour -lt 12 ]
then
msg="Good Morning"
elif [ $currentHour -ge 12 ] && [ $currentHour -lt 16 ]
then
msg="Good Afternoon"
elif [ $currentHour -ge 16 ] && [ $currentHour -lt 21 ]
then
msg="Good Evening"
else
msg="Good Night"
fi
#format of time [ HH : MM : SS : AM/PM]
echo "$msg ,\nCurrent Time is $currentTime"
Labels:
shell script,
unix
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- CSS (3)
- Configure Tomcat7 (2)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- WTAD (34)
- c (11)
- install Tomcat (2)
- linux (8)
- shell script (33)
- unix (22)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
0 comments:
Post a Comment