bash script choice menu from csv file
Hi,
I don't have a lot experience in linux but 2 days ago I wrote my first script. The script starts first a program I wrote earlier that collects specific data from 3 online csv files and write a summary csv file called /Tribalwars/request.csv . The seperator used is ; the csv file looks like this but can be any number of rows (but not to many mostly 3 - 5) Title1;tile2;...;title15; B1;B2;...;B15 C1;C2;...;C15 D1;D2;...;D15 Now the next part of the script, and that is what I want to change, asks me to manually input some data I have to copy paste from the csv file just created. I mean if i choose to continue to do my calculations for city 2, I need to copy-paste C1 for the first variable 'cityname' , copy-paste c2 for the second variable 'xxx',copy-paste C3 for the third variable 'yyy',copy-paste C15 for the fourth variable 'points' Then it starts new calculations etc, witch only these variables. Now could it be possible to make a menu from the csv file with only the according cells on the screen and that I only have to choose a row from the menu? Thank you for reading all this. |
Maybe have a look at select ... it is used in bash to make menus (simple text based ones) and allows you to enter a number to select the item you want to do more with.
|
yes but I need to create the menu first
how shall i create the menu with the data from the csv file |
Here is something to get you going:
Code:
#!/bin/bash |
how should that help me?
|
Have you tried running the code? Grail was kind in giving you actual code to start you off. The "select" command is used for, among other things, making a menu. It makes sure that "opt" is one of the lines in csv_file, then you can run whatever code you like instead of the echo statement. You could try reading this tutorial - it also covers the "case" statement, so scroll down to read the things on select (though you might be interested in the case stuff too!)
|
All times are GMT -5. The time now is 04:16 AM. |