Solution to this must be as intresting as the problem :)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Solution to this must be as intresting as the problem :)
# 1  
Old 11-17-2003
Solution to this must be as intresting as the problem :)

Hi all ,

I am looking for a KSH script to do the following:

1) take input string from a user .
2) grep this string in a file . the file format is like this

FUNCTION homeph_phone_id RETURN NUMBER;
FUNCTION vmph_phone_id RETURN NUMBER;
FUNCTION workph_phone_id RETURN NUMBER;
FUNCTION fax_phone_id RETURN NUMBER;
FUNCTION cell_phone_id RETURN NUMBER;
FUNCTION pg_phone_id RETURN NUMBER;


3) Present this output again back to user and take input for the user selected option.

something like is: In kash command

Enter a word to serach
:
user enter : phone_id

grep through the file ABC .txt (format as mentioned above)

return the output of the grep command in the form of choices ....like

your options are :
------------------------
1)FUNCTION homeph_phone_id RETURN NUMBER;
2)FUNCTION vmph_phone_id RETURN NUMBER;
3)FUNCTION workph_phone_id RETURN NUMBER;
4)FUNCTION fax_phone_id RETURN NUMBER;
5)FUNCTION cell_phone_id RETURN NUMBER;
6)FUNCTION pg_phone_id RETURN NUMBER;

Ask user to enter a choice :
user enters a choice

Dump the choice on a flat file ....

I hope i was clear enough in my requirements .... working on the script myself but not finding a proper way to throw grep output as choices ...

can anyone give me a solution ...

take care
# 2  
Old 11-17-2003
Not sure if this is a homework question or not. Certainly seems as homework.

1) Your search should be case in-sensitive if you want an all inclusive list. For grep, see the -i switch. Also, dont limit yourself to grep, see also egrep or awk. Use what makes sense.
2) for the second menu, see the "select case" method.
3) "Dump the choice on a flat file"Dump only the one line selected by the user to a flat file? Why would this be helpful to anyone?

what is this going to be used for?
# 3  
Old 11-17-2003
Thanks google,

I will let u know specific things what i am looking for .I too think that i was not clear in my question .


Thanks Guys .. i found the way to perform this task now ...

Take care
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. Red Hat

alias ip problem,i canīt find out solution

hi, we have eth1; in the beginning it was proposed to create from eth1, eth1.2500 and eth1.240. It did not worked cause vlan 1.2500 was not tagged in the switch. so they decided to leave eth1 like a physical interface with eth1.2500 config (removel vlan tag) and create eth1.240 but it did... (0 Replies)
Discussion started by: pabloli150
0 Replies
Login or Register to Ask a Question