LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-11-2004, 10:05 PM   #1
Greg_courageous
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!

Thanks!

Greg
 
Old 05-12-2004, 08:32 AM   #2
ranger_nemo
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... << http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html >>
 
Old 05-12-2004, 04:34 PM   #3
Greg_courageous
LQ Newbie
 
Registered: Apr 2004
Posts: 13

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


Reply


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 09:13 PM
simple shell script sharpie Programming 9 06-02-2004 11:47 PM
a simple shell script Warchief Programming 1 07-31-2003 05:01 AM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 10:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 01:36 AM.

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