LinuxForum.Fans
Тема

оператор select

Автор: prostornet 7 сообщений 4034 просмотров
21.03.2014 16:02 · отредактировано #373318

Ни как не могу понять почему оператор select дает вот такой вывод:

text
1) a    3) d   5) g   7) j   9) l  11) w  13) r  15) y  17) i
2) s    4) f   6) h   8) k  10) q  12) e  14) t  16) u  18) o

Сам код:

text

#!/bin/bash

LIST=(a s d f g h j k l q w e r t y u i o)

select VAR in "${LIST[@]}"; do break done

echo ${VAR}

Почему не в столбец?

21.03.2014 16:15 #373321

не знаю как работает в баше ваш select но чую не хватает "\n" где то

21.03.2014 16:23 #373324

И кудаж в операторе я его запихну?

21.03.2014 16:31 #373326

какая то простая задача у Вас.

Вы не могли бы полный текст озвучить?

29.03.2014 22:59 #374568
text
LIST=(a s d f g h j k l q w e r t y u i o)
for x in ${LIST[@]}; do echo "$((++n))) $x"; done
echo -n "#?"
select VAR in ${LIST[@]}; do break; done 2> /dev/null
echo "${VAR}"
14.04.2014 09:14 #376414
"moshell" написал:
не знаю как работает в баше ваш select

select name [ in word ] ; do list ; done
The list of words following in is expanded, generating a list of items. The set of
expanded words is printed on the standard error, each preceded by a number. If the in
word is omitted, the positional parameters are printed (see PARAMETERS below). The PS3
prompt is then displayed and a line read from the standard input. If the line consists
of a number corresponding to one of the displayed words, then the value of name is set
to that word. If the line is empty, the words and prompt are displayed again. If EOF
is read, the command completes. Any other value read causes name to be set to null.
The line read is saved in the variable REPLY. The list is executed after each selec-
tion until a break command is executed. The exit status of select is the exit status
of the last command executed in list, or zero if no commands were executed.
23.01.2015 16:30 #410936

Флуд удалён.

Войдите или зарегистрируйтесь, чтобы ответить.