Get a value from menu.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get a value from menu.
# 1  
Old 01-23-2009
Get a value from menu.

Hi,

I have a shell-script (in bash) wich read from a file this:

1 Telediario 1 2009012609000
2 Mira quien baila 2009012511000
3 No mas 2009012603000
.....
.....
12 Quiero ser tu 20090127113000
13 Al igual que 20090127130000
.....
.....


In the script I would like that the user input a number, and I have to find this number and get the second field and the third field.
for example, he puts 13 and I have to find "Al igual que" and "20090127130000".


could you help me?
Many thanks and sorry for my english!
# 2  
Old 01-23-2009
Simply start with grep command with your input.
# 3  
Old 01-23-2009
Quote:
Originally Posted by mierdatuti
I have a shell-script (in bash) wich read from a file this:

1 Telediario 1 2009012609000
2 Mira quien baila 2009012511000
3 No mas 2009012603000
.....
.....
12 Quiero ser tu 20090127113000
13 Al igual que 20090127130000
.....
.....


In the script I would like that the user input a number, and I have to find this number and get the second field and the third field.
for example, he puts 13 and I have to find "Al igual que" and "20090127130000".


Code:
tab=$'\t'
read num
grep "^$num$tab" | cut -f2-

This User Gave Thanks to cfajohnson For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies

2. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

3. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 Replies

4. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

5. Shell Programming and Scripting

Interactive menu

Hi ,some time ago i did an interactive menu based on eval function for navigation , one of the post remind me it. I think it could be handy for others. #!/usr/bin/ksh keyRead () { tput smso echo "Enter option." tput rmso oldstty=$(stty -g) stty -icanon -echo min 1 time 1 Answer=$(dd... (0 Replies)
Discussion started by: Klashxx
0 Replies

6. Shell Programming and Scripting

Need help with script for menu

I'm working on a script for a basic menu with four options. The first option for the menu asks a user to put in anyone's user name and is supposed to display the user's home directory. If a user does not enter a name, then their own home directory should be displayed. The second menu option is... (0 Replies)
Discussion started by: sinjin
0 Replies

7. Shell Programming and Scripting

Phone menu

Hello, Is there a way to read in user input inside a Here Document? The last line of the add(draft) file is supposed to redirect the user input to the phonebook file, but it is not doing that. I am not sure what I am doing wrong. So the redirected user input should be appended to the... (1 Reply)
Discussion started by: Dawg101
1 Replies

8. Shell Programming and Scripting

Menu

How do i make a menu... I need to be able to select options that run scripts that i make. like displaying/adding/sorting/deleting records of a file. i have the displaying part down but I want to make the menu now then i'll figure out the deleting/adding/sorting. (5 Replies)
Discussion started by: space
5 Replies
Login or Register to Ask a Question