Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-11-2004, 11:05 PM   #1
LQ Newbie
Registered: Apr 2004
Posts: 13

Rep: Reputation: 0
simple shell script

Hello all, I want to write a shell script that would greet you with 'Good Morning' if the time is between 12.00am to 11.59am, 'Good Afternoon' if the time is between 12.00pm to 4.59pm, 'Good Evening' if the time is between 5.00pm to 7.59pm and 'Good Night' if the time is between 8.00pm to 11.59pm.

How would i go about this???
I have basic knowledge of programming in c++, so hopefully i'll be able to catch on!!
any help would be greatly appreciated!


Old 05-12-2004, 09:32 AM   #2
Senior Member
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Do you want a bash script? I usually use Python, but bash will work, too.

In bash, you can use "now = $(date +%H)" to get the hour (0-23). Then, set up a couple if / else-if conditions.

More info at... << >>
Old 05-12-2004, 05:34 PM   #3
LQ Newbie
Registered: Apr 2004
Posts: 13

Original Poster
Rep: Reputation: 0
yeah thats exactly what im after =)
thanks for your help!!!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Shell Script Help Kristijan Programming 3 06-13-2005 10:13 PM
simple shell script sharpie Programming 9 06-03-2004 12:47 AM
a simple shell script Warchief Programming 1 07-31-2003 06:01 AM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 11:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM

All times are GMT -5. The time now is 02:40 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration