Ребят может у кого есть готовые примеры по работе с массивами в скриптах?
Особенно интересует выборка.
Пьянка без секса – признак алкоголизма.
Настоятельно просим вас при общении соблюдать Правила форума и законы РФ. Наша тематика вне политики, поэтому воздержитесь от обсуждения ситуации на Украине и связанных с ней событий, независимо от того, какую сторону вы поддерживаете.
Также напоминаем, что наш форум находится в доменной зоне .ru, физически расположен на российских серверах и мы соблюдаем действующее законодательство России. Любые сообщения о политике будут удаляться.
Linux Forum → Программирование → Массив в скриптах
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
Ребят может у кого есть готовые примеры по работе с массивами в скриптах?
Особенно интересует выборка.
http://www.google.ru/search?client=oper … p;oe=utf-8
с каким именно языком программирования хотите экспериментировать?
Ребят может у кого есть готовые примеры по работе с массивами в скриптах?
Особенно интересует выборка.
вам именно массивы нужны? или строки пойдут?
вот в bash'е:
Arrays
Bash provides one-dimensional array variables. Any variable may be used as an array; the declare builtin
will explicitly declare an array. There is no maximum limit on the size of an array, nor any requirement
that members be indexed or assigned contiguously. Arrays are indexed using integers and are zero-based.
An array is created automatically if any variable is assigned to using the syntax name[subscript]=value.
The subscript is treated as an arithmetic expression that must evaluate to a number greater than or equal
to zero. To explicitly declare an array, use declare -a name (see SHELL BUILTIN COMMANDS below). declare
-a name[subscript] is also accepted; the subscript is ignored. Attributes may be specified for an array
variable using the declare and readonly builtins. Each attribute applies to all members of an array.
Arrays are assigned to using compound assignments of the form name=(value1 ... valuen), where each value
is of the form [subscript]=string. Only string is required. If the optional brackets and subscript are
supplied, that index is assigned to; otherwise the index of the element assigned is the last index
assigned to by the statement plus one. Indexing starts at zero. This syntax is also accepted by the
declare builtin. Individual array elements may be assigned to using the name[subscript]=value syntax
introduced above.
Any element of an array may be referenced using ${name[subscript]}. The braces are required to avoid con‐
flicts with pathname expansion. If subscript is @ or *, the word expands to all members of name. These
subscripts differ only when the word appears within double quotes. If the word is double-quoted,
${name[звёздочка]} expands to a single word with the value of each array member separated by the first character
of the IFS special variable, and ${name[@]} expands each element of name to a separate word. When there
are no array members, ${name[@]} expands to nothing. If the double-quoted expansion occurs within a word,
the expansion of the first parameter is joined with the beginning part of the original word, and the
expansion of the last parameter is joined with the last part of the original word. This is analogous to
the expansion of the special parameters * and @ (see Special Parameters above). ${#name[subscript]}
expands to the length of ${name[subscript]}. If subscript is * or @, the expansion is the number of ele‐
ments in the array. Referencing an array variable without a subscript is equivalent to referencing ele‐
ment zero.
The unset builtin is used to destroy arrays. unset name[subscript] destroys the array element at index
subscript. Care must be taken to avoid unwanted side effects caused by filename generation. unset name,
where name is an array, or unset name[subscript], where subscript is * or @, removes the entire array.
The declare, local, and readonly builtins each accept a -a option to specify an array. The read builtin
accepts a -a option to assign a list of words read from the standard input to an array. The set and
declare builtins display array values in a way that allows them to be reused as assignments.ЗЫЖ звёздочку(*) я заменил на "звёздочка"
ЗЫЖ примечание: в обычной shell как раз массивов-то и нету 
потому скрипты с массивами НЕ переносимы, и не везде будут работать! Потому в начале скрипта пишите
#!/bin/bash(в большинстве систем это не играет роли. Но вот в убунте, по слухам, какой-то свой dash, как и в Debian'е. Кроме того возможны проблемы в BSD)
Я вас предупредил...
ззыж в php массивы есть. очень хорошие. рекомендую (php вообще ИМХО самый лучший из скриптовых ЯП).
примеры нужны?
ззыж в php массивы есть. очень хорошие. рекомендую (php вообще ИМХО самый лучший из скриптовых ЯП).
примеры нужны?
Для каких целей он самый лучший из скриптовых?
drBatty, незнаю как насчет лучшего, но для скриптов, как замену bash, использовать можно =)
elve,
можно узнать, как? Пример?
Для каких целей он самый лучший из скриптовых?
для общих целей. bash очень медленный. если быстродействие не играет роли (а так обычно и бывает, т.к. 80-95% времени занимают разные конструкции на C/C++), то и bash неплох.
можно узнать, как? Пример?
<?php
echo "привет, Мир!"
?>
doc@bx:~$ ./helloword.php
привет, Мир!
у нас на повестке дня массивы. Извольте-с:
Спасибо "drBatty" за примеры просто 3 дня в бане отсиживал
.
Страницы 1
Чтобы отправить ответ, вы должны войти или зарегистрироваться
Linux Forum → Программирование → Массив в скриптах
Форум работает на PunBB, при поддержке Informer Technologies, Inc