Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 04-30-2005, 01:04 AM   #1
LQ Newbie
Registered: Apr 2005
Posts: 5

Rep: Reputation: 0
Question Difficulties writing shell scripts

I dont like to take up people's time but I have taken the below shell scripts as far as I can. I dont think I am capable of any more, and I guess I hate to say it but I need help. Thanks in advance for any assistance anyone can provide. Sorry to be burdonsome. PS: These have been written in vi text editor.

Write a shell script that will 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 it is between 8.00pm to 11.59pm.

greet=`date | cut –c12-13,15-16`;
if [ “$greet” => “0000” –a “$greet” <= “1159” ];
echo “Good Morning!”;
if [ “$greet” => “1200” –a “$greet” <= “1659” ];
echo “Good Afternoon!”;
if [ “$greet” => “1700” –a “$greet” <= “1959” ];
echo “Good Evening”;
echo “Good Night”

Write a shell script which will display a menu as follows and accepts an input key from the user to execute an option on the menu.

My Menu
1) Display today’s date and system uptime
2) Display calendar for a particular month and year
3) Display current logon users
4) Find a file
5) Exit from menu
Please enter your choice (1-5):

For option 2 the user must be allowed to enter the month and the year for calendar display. For option 4 you must use the find command to find the file and the user must be allowed to enter the filename and the name of the directory for the search. Your shell script should run continuously until the user enters 5 for exit.

tput clear;
tput cup 3 17; echo “My Menu”;
tput cup 4 17; echo “~~~~~~~”;
tput cup 6 12; echo “1) Display today’s date and system uptime”;
tput cup 7 12; echo “2) Display calendar for a particular month and year”;
tput cup 8 12; echo “3) Display current logon users”;
tput cup 9 12; echo “4) Find a file”;
tput cup 10 12; echo “5) Exit from menu”;
tput cup 11 17; echo “Please enter your choice (1-5):”; tput cup 11 49;
read choice
if [ “$choice” = “1” ];
tput cup 12 17; date
if [ “$choice” = “2” ];
tput cup 12 17; echo “Please enter month:”; tput cup 12 37;
read month
tput cup 13 17; echo “Please enter year:”; tput cup 13 37;
read year
if [ “$choice” = “3” ];
tput cup 12 17; who
if [ “$choice” = “4” ];
tput cup 12 17; echo “What is the name of the directory?”; tput cup 12 52;
read directory
tput cup 13 17; echo “What is the filename?”; tput cup 13 52;
read filename
tput cup 14 17; find /directory –name filename
Old 04-30-2005, 02:22 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 235Reputation: 235Reputation: 235
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.
Old 05-01-2005, 03:48 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Closed per the above ...

Closed Thread

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
Writing Shell Scripts in Redhat 6.1 KDE Ace Rimmer Linux - Newbie 5 08-16-2016 07:41 PM
Difficulties writing shell scripts lostinsyntax Programming 8 05-02-2005 07:42 AM
I'm terrible at writing shell scripts. A little help fetching files? ashibaka Linux - General 6 04-10-2004 12:41 AM
Writing C++ Shell Scripts MasterKin8T Programming 5 09-29-2003 10:43 AM
writing Linux shell scripts in Windows NightWolf_NZ Linux - Newbie 3 09-10-2003 09:28 PM

All times are GMT -5. The time now is 09:05 PM.

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