Sponsored Content
Top Forums Shell Programming and Scripting Array based selection of values by selecting either index or member Post 303045468 by nezabudka on Thursday 26th of March 2020 08:37:04 AM
Old 03-26-2020
Need to refine error handling
Code:
choose() {
  select button in $@ Quit; do
    case $button in
      Quit)
        echo $REPLY - $button
        break
        ;;
      "") 
        echo ERROR try again
        continue
        ;;
      *)  
        echo you press $REPLY and selected $button
    esac
done
}

choose $listofitems

This User Gave Thanks to nezabudka For This Post:
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

2. UNIX for Dummies Questions & Answers

wh inode index starts from 1 unlike array index (0)

brothers why inode index starts from 1 unlike array inex which starts from 0 its a question from the design of unix operating system of maurice j.bach i need to know the answer urgently...someone help please (1 Reply)
Discussion started by: sairamdevotee
1 Replies

3. Programming

random array index returning values not contained

For kicks I wrote up a Password generator after lunch. Let me start with the code: unsigned int x,y,z,c; unsigned int KISS(); unsigned int devrand(); int main( int argc, char** argv ) { int i, j = 1; char pwd = "abcdefghijklmnopqrstuvwxyz" ... (5 Replies)
Discussion started by: VRoemer
5 Replies

4. Shell Programming and Scripting

PERL - Selecting specific files based on 'date stamp' values

Hi, I've list of files in a directory, which have date stamp value in their names. ex: abc_data_20071102.csv, abc_data_20091221.csv, abc_data_20100110.csv, abc_data_20100222.csv, abc_data_20080620.csv,... etc., I need to select and process only files, within the given date... (4 Replies)
Discussion started by: ganapati
4 Replies

5. Shell Programming and Scripting

Selecting rows based on values in columns

Hi My pipe delimited .txt file contains rows with 10 columns. Can anyone advise how I output to file only those rows with the letters ‘ci' as the first 2 characters in the 3rd column ? Many thanks (4 Replies)
Discussion started by: malts18
4 Replies

6. Programming

Selecting array values

I have two arrays DIST(1:NCOF) and X(1:NX) Let NCOF = 5 and NX = 15, with DIST = and X = I want to create an array that puts a zero if DIST is outside the region in X, otherwise putting 1. In this example I should get RES = Using DIST = would give RES = The values in... (6 Replies)
Discussion started by: kristinu
6 Replies

7. Shell Programming and Scripting

Selecting lowest and highest values in columns 1 and 2, based on subsets in column 3

Hi, I have a file with the following columns: 361459 447394 CHL1 290282 290282 CHL1 361459 447394 CHL1 361459 447394 CHL1 178352861 178363529 AGA 178352861 178363529 AGA 178363657 178363657 AGA Essentially, using CHL1 as an example. For any line that has CHL1 in... (2 Replies)
Discussion started by: hubleo
2 Replies

8. Shell Programming and Scripting

build array name based on loop index

Hi, I am new to perl and I have the following query please help here. I have following array variables declaration @pld1 = qw(00 01 02 03 04 05); @pld2 = qw(10 11 12 13 14 15); for(my $k=1;$k<=2;$k++) { //I want here to use @pld1 if $k is 1 // and @pld2 if $k is 2. How to do... (3 Replies)
Discussion started by: janavan
3 Replies

9. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

10. Shell Programming and Scripting

Find minimum and maximum values based on column with associative array

Hello, I need to find out the minimum and maximum values based on specific column, and then print out the entire row with the max value. Infile.txt: scf6 290173 290416 . + X_047241 T_00113118-1 scf6 290491 290957 . + X_047241 T_00113118-2 scf6 290898 290957 . + X_047241 T_00113119-3 scf6... (2 Replies)
Discussion started by: yifangt
2 Replies
XMESSAGE(1)						      General Commands Manual						       XMESSAGE(1)

NAME
xmessage - display a message or query in a window (X-based /bin/echo) SYNOPSIS
xmessage [ -buttons label1[:value1],label2[:value2], ... ] [ options ] -file filename xmessage [ -buttons label1[:value1],label2[:value2], ... ] [ options ] message ... DESCRIPTION
The xmessage program displays a window containing a message from the command line, a file, or standard input. Along the lower edge of the message is row of buttons; clicking the left mouse button on any of these buttons will cause xmessage to exit. Which button was pressed is returned in the exit status and, optionally, by writing the label of the button to standard output. The program is typically used by shell scripts to display information to the user or to ask the user to make a choice. Unless a size is specified, xmessage sizes itself to fit the message, up to a maximum size. If the message is too big for the window, xmessage will display scroll bars. OPTIONS
These are the command line options that xmessage understands. -buttons button,button,... This option will cause xmessage to create one button for each comma-separated button argument. The corresponding resource is but- tons. Each button consists of a label optionally followed by a colon and an exit value. The label is the name of the Command but- ton widget created and will be the default text displayed to the user. Since this is the name of the widget it may be used to change any of the resources associated with that button. The exit value will be returned by xmessage if that button is selected. The default exit value is 100 plus the button number. Buttons are numbered from the left starting with one. The default string if no -buttons option is given is okay:0. -default label Defines the button with a matching label to be the default. If not specified there is no default. The corresponding resource is defaultButton. Pressing Return anywhere in the xmessage window will activate the default button. The default button has a wider border than the others. -file filename File to display. The corresponding resource is file. A filename of `-' reads from standard input. If this option is not sup- plied, xmessage will display all non-option arguments in the style of echo. Either -file or a message on the command line should be provided, but not both. -print This will cause the program to write the label of the button pressed to standard output. Equivalent to setting the printValue resource to TRUE. This is one way to get feedback as to which button was pressed. -center Pop up the window at the center of the screen. Equivalent to setting the center resource to TRUE. -nearmouse Pop up the window near the mouse cursor. Equivalent to setting the nearMouse resource to TRUE. -timeout secs Exit with status 0 after secs seconds if the user has not clicked on a button yet. The corresponding resource is timeout. WIDGET HIERARCHY
Knowing the name and position in the hierarchy of each widget is useful when specifying resources for them. In the following chart, the class and name of each widget is given. Xmessage (xmessage) Form form Text message Command (label1) Command (label2) . . . RESOURCES
The program has a few top-level application resources that allow customizations that are specific to xmessage. file A String specifying the file to display. buttons A String specifying the buttons to display. See the -buttons command-line option. defaultButton A String specifying a default button by label. printValue A Boolean value specifying whether the label of the button pressed to exit the program is written to standard output. The default is FALSE. center A Boolean value specifying whether to pop up the window at the center of the screen. The default is FALSE. nearMouse A Boolean value specifying whether to pop up the window near the mouse cursor. The default is FALSE. timeout The number of seconds after which to exit with status 0. The default is 0, which means never time out. maxHeight (class Maximum) The maximum height of the text part of the window in pixels, used if no size was specified in the geometry. The default is 0, which means use 70% of the height of the screen. maxWidth (class Maximum) The maximum width of the text part of the window in pixels, used if no size was specified in the geometry. The default is 0, which means use 70% of the width of the screen. ACTIONS
exit(value) exit immediately with an exit status of value (default 0). This action can be used with translations to provide alternate ways of exiting xmessage. default-exit() exit immediately with the exit status specified by the default button. If there is no default button, this action has no effect. EXIT STATUS
If it detects an error, xmessage returns 1, so this value should not be used with a button. SEE ALSO
X(7), echo(1), cat(1) AUTHORS
Chris Peterson, MIT Project Athena Stephen Gildea, X Consortium X Version 11 xmessage 1.0.2 XMESSAGE(1)
All times are GMT -4. The time now is 10:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy