Select One

last modified: July 10, 2008

SelectOne is a command line pattern of ksh, bash, and perhaps the other conforming PosixShell

select name in $list ; do ComethingTo $name ; done

Here's a real example, but I haven't ReFactored the SomethingTo part -- it's hard coded on my CommandLine -- AnySuggestions? We can't offer suggestions unless we know what you're even trying to do or communicate here. Can you elucidate more on what your example is supposed to convey? So far, it looks identical to the BashShell for command. E.g., for x in `ls | grep Ward`; do (cat $x | WikiWord); done

# 01:23:39 garrod@humu 3.34 $ cd ~/wiki && select name in `ls |grep Ward`;do cat $name|WikiWord ;done
1) ActressWard            5) PsychWard             9) WardsWiki
2) AwkWard                6) WardAndKaren         10) WardsWikiPages
3) ChrisAndWard           7) WardCunningham       11) WardsWikiWords
4) NewAtWardsWiki         8) WardholmeTorreyPine  12) WardsWikiWordsRld
Pick a number:  8
1  WikiWord
-- -------
1  CategoryTree
1  TreeFlossed
1  CarpinteriaAvenue
1  SeaLevel
1  WardholmeTorreyPine
1  WorldsLargest
-  --------
1  WikiWord
1 WikiWord
Pick a number:

I ended the above select statement with a control-D. The Pick a number: prompt is set in bash by environmental variable PS3


CategoryUnixShellPattern


Loading...