Sponsored Content
Full Discussion: Selection from array
Top Forums Shell Programming and Scripting Selection from array Post 303024335 by bignellrp on Saturday 6th of October 2018 01:24:20 PM
Old 10-06-2018
Wow. Thanks so much bakunin. You are certainly right that it is better to "teach a man to fish". I struggled with this for hours before i posted as it was hard finding something on google that was relevant enough to my problem to learn from. So now not only am i one step closer to resolving my problem i have learned a lot more.

I'll have a play and let you know how i get on.

------ Post updated at 05:24 PM ------

Having much more fun now i know how the array works, but I'm struggling to get the row to display as a whole selection. The array is splitting all the individual items into options.

I want to display like:

1. apples : 1111 : aaaa
2. pears : 2222 : bbbb
3. peaches : 3333 : cccc

but its displaying

1. apples
2. 1111
3. aaaa
4. pears
5. 2222

etc

Here is my new code:

Code:
options=( $(awless -l list routetables --columns ID,NAME,VPC --filter VPC=vpc-0025xxxxxxxe52 | grep rtb | sed 's/|//g') )
selection=""
options[((${#options[@]}+1))]="EXIT"

selection=""

PS3="Enter 1-$((${#options[@]}-1)) to select an item or ${#options[@]} to exit => "

#PS3="Select an item or 5 to exit => "
select selection in ${options[@]} ; do
     case "$selection" in
          "")
               echo "You selected a non-existing item"
               ;;

          "EXIT")
               echo "You are leaving the loop."
               break
               ;;

          *)
               echo "You selected $selection"
               ;;

     esac
done

echo "here is the end of the program"
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Array and Selection

I have a question: Y X Tabel a is a array multidimensional --> a(1024,20) I load in to array a Text from 6000 row where: in a(1,1) is present the row 1 of original text, in a(1024,1) is present then row 1024 of original test and in... (4 Replies)
Discussion started by: ZINGARO
4 Replies

2. UNIX for Advanced & Expert Users

tray selection

Hello All, Could anyone help me how to selecting the trays in unix . Thanks, Amit kul (3 Replies)
Discussion started by: amit kul
3 Replies

3. Post Here to Contact Site Administrators and Moderators

Opt out selection

Maybe I'm missing something but when I go to CP->Options, I see the box for selecting which forum to opt out of but no way to set it. (5 Replies)
Discussion started by: drhowarddrfine
5 Replies

4. Shell Programming and Scripting

Menu help with array selection

Hi there all I got the following I got multiple arrays named for example STAT_AAAA STAT_AAAB STAT_AAAC STAT_AAAD Now what I want I have chosen an option in a menu to select 1 but I dont want to write for all the same thing so I made it a signle one now what I want is to get STAT_ and... (6 Replies)
Discussion started by: draco
6 Replies

5. Shell Programming and Scripting

Data selection

Hi, I have a file containing details of different departments . Infomration of departments is in various tags file is as below I want to create a new file from the above file which should contain only two fields belonging to one department format There are multiple files... (1 Reply)
Discussion started by: test_user
1 Replies

6. Shell Programming and Scripting

Data selection

Hi, Please note that as a programmer I cannot tell the file format or details of my production files so I have re-framed my file and taken a case of departments. Kindly guide as its related to a production requirement of data containing recors of production customer NOT A HOMEWORK :) I have... (10 Replies)
Discussion started by: test_user
10 Replies

7. AIX

Bulk Fixes Selection

Under smit, one has to manually select each fix with F7. there 9000 fixes left to be marked. How Can I manually install/Mark all of these without SMIT. ---------- Post updated at 02:29 PM ---------- Previous update was at 01:15 PM ---------- From the command line instfix -T -d... (4 Replies)
Discussion started by: mrmurdock
4 Replies

8. UNIX for Dummies Questions & Answers

awk for column selection

Hello, I want to extract all values from table except for those that contain the '*' character in the second column. I tried awk '$2!=*' and this threw a syntax error. Do I need to specify an escape character or != is valid only for numerical comparisons? Thanks, Guss (1 Reply)
Discussion started by: Gussifinknottle
1 Replies

9. Shell Programming and Scripting

Date selection

Hi All, i have log file sample data is 2010/10/09|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/08|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/07|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/05|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/03|04:00:00.392|15Minute|BW=0|192.168.0.1... (2 Replies)
Discussion started by: posner
2 Replies

10. Shell Programming and Scripting

If Selection statement

ok im kinda stuck i have a bash script with 4 options 1. Create Script 2. Show Script 3 . Delete script 4. Exithow would i use an if statement for this? im not sure what test command i would use. I know it would be like this (below) to display the script if then cat script1or for the... (10 Replies)
Discussion started by: gangsta
10 Replies
Tk_CanvasTextInfo(3)					       Tk Library Procedures					      Tk_CanvasTextInfo(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_CanvasTextInfo - additional information for managing text items in canvases SYNOPSIS
#include <tk.h> Tk_CanvasTextInfo * Tk_CanvasGetTextInfo(canvas) ARGUMENTS
Tk_Canvas canvas (in) A token that identifies a particular canvas widget. _________________________________________________________________ DESCRIPTION
Textual canvas items are somewhat more complicated to manage than other items, due to things like the selection and the input focus. Tk_CanvasGetTextInfo may be invoked by a type manager to obtain additional information needed for items that display text. The return value from Tk_CanvasGetTextInfo is a pointer to a structure that is shared between Tk and all the items that display text. The structure has the following form: typedef struct Tk_CanvasTextInfo { Tk_3DBorder selBorder; int selBorderWidth; XColor *selFgColorPtr; Tk_Item *selItemPtr; int selectFirst; int selectLast; Tk_Item *anchorItemPtr; int selectAnchor; Tk_3DBorder insertBorder; int insertWidth; int insertBorderWidth; Tk_Item *focusItemPtr; int gotFocus; int cursorOn; } Tk_CanvasTextInfo; The selBorder field identifies a Tk_3DBorder that should be used for drawing the background under selected text. selBorderWidth gives the width of the raised border around selected text, in pixels. selFgColorPtr points to an XColor that describes the foreground color to be used when drawing selected text. selItemPtr points to the item that is currently selected, or NULL if there is no item selected or if the canvas does not have the selection. selectFirst and selectLast give the indices of the first and last selected characters in selItemPtr, as returned by the indexProc for that item. anchorItemPtr points to the item that currently has the selection anchor; this is not neces- sarily the same as selItemPtr. selectAnchor is an index that identifies the anchor position within anchorItemPtr. insertBorder contains a Tk_3DBorder to use when drawing the insertion cursor; insertWidth gives the total width of the insertion cursor in pixels, and insertBor- derWidth gives the width of the raised border around the insertion cursor. focusItemPtr identifies the item that currently has the input focus, or NULL if there is no such item. gotFocus is 1 if the canvas widget has the input focus and 0 otherwise. cursorOn is 1 if the insertion cursor should be drawn in focusItemPtr and 0 if it should not be drawn; this field is toggled on and off by Tk to make the cur- sor blink. The structure returned by Tk_CanvasGetTextInfo is shared between Tk and the type managers; typically the type manager calls Tk_CanvasGet- TextInfo once when an item is created and then saves the pointer in the item's record. Tk will update information in the Tk_CanvasTex- tInfo; for example, a configure widget command might change the selBorder field, or a select widget command might change the selectFirst field, or Tk might change cursorOn in order to make the insertion cursor flash on and off during successive redisplays. Type managers should treat all of the fields of the Tk_CanvasTextInfo structure as read-only, except for selItemPtr, selectFirst, select- Last, and selectAnchor. Type managers may change selectFirst, selectLast, and selectAnchor to adjust for insertions and deletions in the item (but only if the item is the current owner of the selection or anchor, as determined by selItemPtr or anchorItemPtr). If all of the selected text in the item is deleted, the item should set selItemPtr to NULL to indicate that there is no longer a selection. KEYWORDS
canvas, focus, insertion cursor, selection, selection anchor, text Tk 4.0 Tk_CanvasTextInfo(3)
All times are GMT -4. The time now is 07:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy