Tru to print the last name and first name using key word

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Tru to print the last name and first name using key word
# 1  
Old 07-22-2013
Tru to print the last name and first name using key word

I am new to shell scripting and trying to do the below

Code:
Stan:Smith:Detroit:MI
Jim:Jones:Farmington Hills:MI
Jack:Frost:Denver:CO
Sue:Apple:New York:NY
Cindy:Thompson:Battle Creek:MI
John:Smith:Denver:CO
George:Jones:New York:NY

Need to create a shell script This script will display the following information in a menu format:
Code:
                        L - Print Last Names
                        F - Print First Names
                        C - Print First Name, Last Name sorted by city
                        S - Print First Name, Last Name, State sorted by state
                        Q - Exit the program

The script will perform all of the actions listed above on your file and loop until Q key is pressed.

[COLOR="#738fbf"]---------- Post updated at 03:03 PM ---------- Previous update was at 03:00 PM ----------[/color

I did the below but not working...

Code:
loop=y
while [ "$loop" = y ]
do
clear
tput cup 3 12; echo "P - Print Last Name"
tput cup 10 9; echo "Q - Quit: "
tput cup 10 19;
read choice || continue
case $choice in
[Pp]) less ~/export/home/mathews/homework2;;
[Qq]) exit ;;
*) tput cup 14 4; echo "Invalid Code"; read choice ;;
esac
done

Moderator's Comments:
Mod Comment code tags for code please, not font, not color

Last edited by Corona688; 07-22-2013 at 04:24 PM..
# 2  
Old 07-22-2013
Please follow forum rules - there is a format that you need to use to submit homework. We will be glad to help you but please follow the prescribed format.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i replace a word ending with "key" using awk excpet for one word?

echo {mbr_key,grp_key,dep_key,abc,xyz,aaa,ccc} | awk 'gsub(/^|abc,|$/,"") {print}' Required output {grp_key,xyz,aaa,ccc} (5 Replies)
Discussion started by: 100bees
5 Replies

2. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

3. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

4. Shell Programming and Scripting

[Solved] Search for a word and print the next word

Hi, I am trying to search for a word and print the next word. For example: My text is "<TRANSFORMATION TYPE ="Lookup Procedure">" I am searching for "TYPE" and trying to print ="Lookup Procedure" I have written a code like following: echo $line | nawk... (4 Replies)
Discussion started by: sampoorna
4 Replies

5. Shell Programming and Scripting

perl lwp find word and print next word :)

hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this: I have in my response lines like: <div class="sender">mimi020</div> <some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies

6. UNIX for Dummies Questions & Answers

Script to search for a particular word in files and print the word and path name

Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name". Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies

7. Shell Programming and Scripting

print lines from a file containing key word

i have a file containing over 1 million records,and i want to print about 300,000 line containing a some specific words. file has content. eg 1,rrt,234 3,fgt,678 4,crf,456 5,cde,drt 6,cfg,123 and i want to print the line with the word fgt,crf this is just an example,my file is so... (2 Replies)
Discussion started by: tomjones
2 Replies

8. Shell Programming and Scripting

perl (word by word check if a hash key)

Hi, Now i work in a code that 1-get data stored in the database in the form of hash table with a key field which is the " Name" 2-in the same time i open a txt file and loop through it word by word 3- which i have a problem in is that : I need to loop word by word and check if it is a... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

9. Shell Programming and Scripting

key word parameter

cat shell_script.ksh x=$A y=$B export x export y echo $x echo $y when i am running this with a command ksh shell_script.ksh -A 10 -B 20 its not showing anything .... could you let me know how i can use key word type paramter (2 Replies)
Discussion started by: dr46014
2 Replies

10. UNIX for Dummies Questions & Answers

Searching for key word within a file

Hello, I have a directory that holds all of my matlab codes. I am trying to run a searh on all of the matlab files that have the word "while" written inside the sytax of the code. Looking for all of the times that I did a while loop. Can someone help me do this? Thanks in advance. ... (1 Reply)
Discussion started by: moradwan
1 Replies
Login or Register to Ask a Question