<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; Массив в скриптах]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=8575&amp;type=atom" />
	<updated>2010-11-30T15:33:11Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=8575</id>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=117702#p117702" />
			<content type="html"><![CDATA[<p>Спасибо &quot;drBatty&quot; за примеры просто 3 дня в бане отсиживал&nbsp; <img src="https://linuxforum.ru/img/smilies/ag.gif" alt="ag" /> .</p>]]></content>
			<author>
				<name><![CDATA[Kettler]]></name>
				<uri>https://linuxforum.ru/profile.php?id=11719</uri>
			</author>
			<updated>2010-11-30T15:33:11Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=117702#p117702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=116232#p116232" />
			<content type="html"><![CDATA[<p>у нас на повестке дня массивы. Извольте-с:<br /><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh">doc@bx:~$ cat ./helloword.php <br />#!/usr/bin/php<br />&lt;?php<br />&nbsp; &nbsp; $a = array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;);<br />&nbsp; &nbsp; foreach($a as $e)<br />&nbsp; &nbsp; &nbsp; &nbsp; echo $e . &quot;\n&quot;;<br />?&gt;<br />doc@bx:~$ ./helloword.php <br />a<br />b<br />c<br /></div></p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-11-25T23:25:20Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=116232#p116232</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=116231#p116231" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Hvzh пишет:</cite><blockquote><p>Для каких целей он самый лучший из скриптовых?</p></blockquote></div><p>для <strong>общих</strong> целей. bash очень медленный. если быстродействие не играет роли (а так обычно и бывает, т.к. 80-95% времени занимают разные конструкции на C/C++), то и bash неплох.<br /></p><div class="quotebox"><cite>Hvzh пишет:</cite><blockquote><p>можно узнать, как? Пример?</p></blockquote></div><p><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh">doc@bx:~$ cat ./helloword.php <br />#!/usr/bin/php</p><p>&lt;?php<br />&nbsp; &nbsp; echo &quot;привет, Мир!&quot;<br />?&gt;</p><p>doc@bx:~$ ./helloword.php </p><p>привет, Мир!<br /></div></p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-11-25T23:20:37Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=116231#p116231</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=116157#p116157" />
			<content type="html"><![CDATA[<p><strong>elve</strong>, <br />можно узнать, как? Пример?</p>]]></content>
			<author>
				<name><![CDATA[Hvzh]]></name>
			</author>
			<updated>2010-11-25T16:36:39Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=116157#p116157</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=116047#p116047" />
			<content type="html"><![CDATA[<p><strong>drBatty</strong>, незнаю как насчет лучшего, но для скриптов, как замену bash, использовать можно =)</p>]]></content>
			<author>
				<name><![CDATA[elve]]></name>
				<uri>https://linuxforum.ru/profile.php?id=1172</uri>
			</author>
			<updated>2010-11-25T07:54:49Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=116047#p116047</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=116033#p116033" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>drBatty пишет:</cite><blockquote><p>ззыж в<strong> php</strong> массивы есть. очень хорошие. рекомендую (php вообще ИМХО самый лучший из скриптовых ЯП).<br />примеры нужны?</p></blockquote></div><p>Для каких целей он самый лучший из скриптовых?</p>]]></content>
			<author>
				<name><![CDATA[Hvzh]]></name>
			</author>
			<updated>2010-11-25T05:58:57Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=116033#p116033</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=115533#p115533" />
			<content type="html"><![CDATA[<p>ззыж в<strong> php</strong> массивы есть. очень хорошие. рекомендую (php вообще ИМХО самый лучший из скриптовых ЯП).<br />примеры нужны?</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-11-23T12:21:16Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=115533#p115533</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=115529#p115529" />
			<content type="html"><![CDATA[<p>ЗЫЖ примечание: в обычной shell как раз массивов-то и нету <img src="https://linuxforum.ru/img/smilies/ac.gif" alt="ac" /><br />потому скрипты с массивами <strong>НЕ переносимы</strong>, и не везде будут работать! Потому в начале скрипта пишите <br /></p><div class="codebox"><pre><code>#!/bin/bash</code></pre></div><p>(в большинстве систем это не играет роли. Но вот в убунте, по слухам, какой-то свой dash, как и в Debian&#039;е. Кроме того возможны проблемы в BSD)<br />Я вас предупредил...</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-11-23T12:16:28Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=115529#p115529</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=115524#p115524" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Kettler пишет:</cite><blockquote><p>Ребят может у кого есть готовые примеры по работе с массивами в скриптах?<br />Особенно интересует выборка.</p></blockquote></div><p>вам именно массивы нужны? или строки пойдут?</p><p>вот в bash&#039;е:<br /></p><div class="codebox"><pre><code>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.</code></pre></div><p><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh">doc@bx:~/tests$ declare array X <br />doc@bx:~/tests$ X[&#039;other&#039;]=&quot;другое&quot;<br />doc@bx:~/tests$ echo ${X[звёздочка]}<br />другое<br />doc@bx:~/tests$ echo ${X[@]}<br />другое<br />doc@bx:~/tests$ X[1]=&quot;один&quot;<br />doc@bx:~/tests$ X[2]=&quot;два&quot;<br />doc@bx:~/tests$ X[3]=&quot;три&quot;<br />doc@bx:~/tests$ echo ${X[звёздочка]}<br />другое один два три<br />doc@bx:~/tests$ echo ${X[2]}<br />два<br />doc@bx:~/tests$ echo ${X[&#039;other&#039;]}<br />другое<br /></div><br />в sed массивов нету ;-(<br />в gawk есть, но я не использую gawk.<br />в пайтоне есть куча всего интересного (кортёжи, словари и прочее)<br />в C массивов нет, есть оператор []. В C++ этот оператор можно перезагружать, что позволяет сделать имитацию массивов. Что вас конкретно интересует?</p><p>ЗЫЖ звёздочку(*) я заменил на &quot;звёздочка&quot;</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-11-23T12:10:09Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=115524#p115524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=115495#p115495" />
			<content type="html"><![CDATA[<p><a href="http://www.google.ru/search?client=opera&amp;rls=ru&amp;q=%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0+%D1%81+%D0%BC%D0%B0%D1%81%D1%81%D0%B8%D0%B2%D0%B0%D0%BC%D0%B8&amp;sourceid=opera&amp;ie=utf-8&amp;oe=utf-8">http://www.google.ru/search?client=oper … p;oe=utf-8</a><br />с каким именно языком программирования хотите экспериментировать?</p>]]></content>
			<author>
				<name><![CDATA[Leviafan]]></name>
				<uri>https://linuxforum.ru/profile.php?id=964</uri>
			</author>
			<updated>2010-11-23T10:54:24Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=115495#p115495</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Массив в скриптах]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=115383#p115383" />
			<content type="html"><![CDATA[<p>Ребят может у кого есть готовые примеры по работе с массивами в скриптах?<br />Особенно интересует выборка.</p>]]></content>
			<author>
				<name><![CDATA[Kettler]]></name>
				<uri>https://linuxforum.ru/profile.php?id=11719</uri>
			</author>
			<updated>2010-11-22T20:38:56Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=115383#p115383</id>
		</entry>
</feed>
