Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-13-2012
Registered User
 
Join Date: May 2009
Posts: 136
Thanks: 25
Thanked 0 Times in 0 Posts
SELECT and wrapping to next column

Hi all,

Am trying to write a menu driven script using SELECT and if I have more than 4 options, it wraps to the next column. That is if I have 6 choices, items 5 and 6 are in the second column.

Is there any settings that control this behavior or is it due to some stty settings?

stty -a output as below:


Code:
speed 38400 baud; rows 38; columns 150; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

It does not wrap to the second column using KSH88 but on PD KSH v5.2.14 99/07/13.2, it does ... Frustrating that I have three different KSH versions ... aaarrgghhh
Sponsored Links
    #2  
Old 09-13-2012
Registered User
 
Join Date: Oct 2010
Location: Southern NJ, USA (Nord)
Posts: 3,806
Thanks: 8
Thanked 469 Times in 449 Posts
Let your lists be vertical and limitless using '\'
Code:
$ echo 1\
>  2
1 2
$

Sponsored Links
    #3  
Old 09-14-2012
cfajohnson's Avatar
Shell programmer, author
 
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,866
Thanks: 0
Thanked 100 Times in 93 Posts

Don't use select ; it doesn't give you much control.
    #4  
Old 09-17-2012
Registered User
 
Join Date: Oct 2010
Location: Southern NJ, USA (Nord)
Posts: 3,806
Thanks: 8
Thanked 469 Times in 449 Posts
True, I only use "for <var> in <list> ; do ... done" and even more often, being more robust and low latency, (parens needed in BASH) "(while read <vars> ; do ... done)", either with a pipe "echo <list>|tr ' ' '\12'|...." or a Here Document (great for managing lists one item per line) "... <<-!\n\tItem1\n\tItem2\n...\n!\n".
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Select record having different value in second column Sanjeev Yadav Shell Programming and Scripting 6 05-17-2012 08:32 AM
select last column mjomba Shell Programming and Scripting 3 03-05-2011 02:56 PM
to select according to the second column..!! adityamitra UNIX for Dummies Questions & Answers 4 06-01-2010 10:59 AM
SQL select all but not if it is already in an other column lowmaster Shell Programming and Scripting 6 02-14-2010 10:02 AM
select a column alfreale Shell Programming and Scripting 2 06-16-2008 06:45 AM



All times are GMT -4. The time now is 05:59 PM.