![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Echo with ksh shell | Khoomfire | UNIX for Advanced & Expert Users | 10 | 01-17-2008 10:04 AM |
| run a shell script with echo | keerthi | UNIX for Advanced & Expert Users | 7 | 06-21-2006 05:38 PM |
| FTP--How to use echo?? | rahul26 | UNIX for Advanced & Expert Users | 1 | 06-14-2006 09:47 AM |
| Echo escaped \c in SH Shell Any Idea | asami | Shell Programming and Scripting | 4 | 05-04-2006 07:24 AM |
| echo $SHELL, $PWD and etc. | yls177 | UNIX for Dummies Questions & Answers | 10 | 12-30-2002 10:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell and echo
Probably my first post, very new to shell scripting
![]() Here is the script i am trying to modify to use function Code:
# Script to create simple menus and take action according to that selected
# menu item
#
while :
do
clear
echo "-------------------------------------"
echo " Main Menu "
echo "-------------------------------------"
echo "[1] Show Todays date/time"
echo "[2] Show files in current directory"
echo "[3] Show calendar"
echo "[4] Start editor to write letters"
echo "[5] Exit/Stop"
echo "======================="
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) echo "Today is `date` "; echo "press a key. . ." ; read ;;
2) echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;
3) cal ; echo "Press a key. . ." ; read ;;
4) vi ;;
5) exit 0 ;;
*) echo "Opps!!! Please select choice 1,2,3,4, or 5"; echo "Press a key. . ." ; read ;;
esac
done
i wan tto replace < echo "press a key. . ." ; read ;;> with a function as it is repeating five times. so i wrote a function like below and called at the right place as shown below, but it didnt worked, any reason ? Code:
.
.
.
read yourch
case $yourch in
1) echo "Today is `date` "; _mesg;;
2) echo "Files in `pwd`" ; ls -l ; echo "Press a key. . ." ; read ;;
3) cal ; echo "Press a key. . ." ; read ;;
4) vi ;;
5) exit 0 ;;
*) echo "Opps!!! Please select choice 1,2,3,4, or 5"; echo "Press a key. . ." ; read ;;
esac
done
_mesg(){
echo "press a key. . ." ; read ;
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|