•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 401,434 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,860 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 7527 | Replies: 11
![]() |
•
•
Join Date: Mar 2004
Location: Arizona
Posts: 24
Reputation:
Rep Power: 5
Solved Threads: 0
I have been tasked to write this shell script in Linux and I dont know how to begin. Can anyone help me out with this please.:cry:
Create a shell script file called “lookup� with a loop that prompts the user for a name to search on, reads a name the user inputs from the keyboard into a shell variable, prints the number of matches that are in your phonebook file as well as the matched name(s) and phone number(s), and keeps looping back until the user enters “quit�. Turn in the final code for this script. If your script doesn’t work, you can still get partial credit based on how close to making it work you get. Full credit will require appropriate spacing, indentation to make your script code easier to read, comments within the script documenting your code flow, and user friendly features/prompts. This will require that you use shell script variables, input, output, counting and looping commands. Your script must contain those types of shell script operations in order to receive full credit.
You will need to change the permissions on the “lookup� file so that it is executable before the script can be run, and you will also probably have to specify the path to the file to get it to run. (type /home/demo/lookup or ~/lookup or ./lookup)
Create a shell script file called “lookup� with a loop that prompts the user for a name to search on, reads a name the user inputs from the keyboard into a shell variable, prints the number of matches that are in your phonebook file as well as the matched name(s) and phone number(s), and keeps looping back until the user enters “quit�. Turn in the final code for this script. If your script doesn’t work, you can still get partial credit based on how close to making it work you get. Full credit will require appropriate spacing, indentation to make your script code easier to read, comments within the script documenting your code flow, and user friendly features/prompts. This will require that you use shell script variables, input, output, counting and looping commands. Your script must contain those types of shell script operations in order to receive full credit.
You will need to change the permissions on the “lookup� file so that it is executable before the script can be run, and you will also probably have to specify the path to the file to get it to run. (type /home/demo/lookup or ~/lookup or ./lookup)
:cool:
•
•
Join Date: Mar 2004
Location: Arizona
Posts: 24
Reputation:
Rep Power: 5
Solved Threads: 0
I have a file called phonebook and these are the names in there. I am starting to learn the commands in my class, but dont know how to write scripts.
Auvenshine:Jason
O Box 18076:85731:7905810
Sepulveda:Mary:7234 Lucky Lane:85705:5551212
Smith:John:3831 E. Camino Seco:85710:6034426
Crowder:Laura
O Box 3261:85747:2771819
Garnett
haron:19872 S. Camino Verde:85744:7293888
Auvenshine:Jason
O Box 18076:85731:7905810Sepulveda:Mary:7234 Lucky Lane:85705:5551212
Smith:John:3831 E. Camino Seco:85710:6034426
Crowder:Laura
O Box 3261:85747:2771819Garnett
haron:19872 S. Camino Verde:85744:7293888 :cool:
•
•
Join Date: Mar 2004
Location: Arizona
Posts: 24
Reputation:
Rep Power: 5
Solved Threads: 0
This is what I have so far, let me know if this is the right, please:
The folder my phonebook is in is called 'phonebook'
1.Now how will I make the script search for names until I enter quit
2. Where would I put in the input value of the name, isnt it called '$1'
3. Also within the search I am doing, how can I make it display the name and phone number when I execute the program.
4. I think its the read command but I'm not sure
Finally, thanks for helping me out.
#! /bin/bash
phonebook=0
echo "Enter a name to search for"
The folder my phonebook is in is called 'phonebook'
1.Now how will I make the script search for names until I enter quit
2. Where would I put in the input value of the name, isnt it called '$1'
3. Also within the search I am doing, how can I make it display the name and phone number when I execute the program.
4. I think its the read command but I'm not sure
Finally, thanks for helping me out.
#! /bin/bash
phonebook=0
echo "Enter a name to search for"
:cool:
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple bbc cd cellphone choose computer core debian dell desktop development enterprise fedora games garnet gentoo gpl hardware ibm infrastructure install kernel laptop linux microsoft mobile news novell open open source openbsd openoffice operating os palm palmos red hat scripting security server source sun suse system ubuntu unix vista web web development windows
- new to linux shell script??????? (Shell Scripting)
- Shell Script Issue (Shell Scripting)
- Linux Shell Script (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: Save ME
- Next Thread: Script needed to check OID values


Linear Mode