The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help mounting a phone! Danny Fozard BSD 2 01-09-2008 04:15 PM
Phone menu Dawg101 Shell Programming and Scripting 1 05-27-2007 10:12 AM
Phone dialer? Sonshyne5 UNIX for Advanced & Expert Users 10 07-17-2003 11:01 AM
Phone Directory MaRk2002 Shell Programming and Scripting 3 01-28-2002 02:41 PM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Jan 2008
Posts: 6
Phone Shell Script !?

could you please find a solution for this

script (called phone) that creates a simple telephone list (create an empty file called “phonlist” in home directory) . Each line in this file consist of two fields name and the phone number, the script should do the following:
When user types the command : “phone new <name> <number>” this will add new record (name,number) to the list.
When user type command: “phone <name>” then the script should search in the file “phonelist” and gets the phone number and display the result.
Forum Sponsor
  #2 (permalink)  
Old 02-03-2008
mirusnet's Avatar
Registered User
 

Join Date: Dec 2007
Posts: 122
Just a principle:
Code:
#! /bin/sh

if [ "$#" -eq 0 ]
then
        exit 1;
fi

if [ "${1}" = "new" ]
then
        echo "${2} ${3}" >> file

else
        cat file | grep "${1}";
fi



exit 0
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0