<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>飞扬轻狂&#039;s blog &#187; shell</title>
	<atom:link href="http://blog.fallseir.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fallseir.com</link>
	<description>我心飞扬 我意轻狂</description>
	<lastBuildDate>Thu, 06 May 2010 07:13:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='blog.fallseir.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>shell 中使用数组 array</title>
		<link>http://blog.fallseir.com/2008/10/array_in_shell/</link>
		<comments>http://blog.fallseir.com/2008/10/array_in_shell/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 07:17:15 +0000</pubDate>
		<dc:creator>飞扬轻狂</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[笔记]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[数组]]></category>

		<guid isPermaLink="false">http://blog.fallseir.com/?p=94</guid>
		<description><![CDATA[发现shell中的数组使用方法 fallseir &#8212; http://blog.fallseir.com/2008/10/array_in_shell/ $ arr=(123 34 3 5) $ echo $arr // 默认获取第一个元素 > 123 $ echo ${arr[1]} // 通过下标访问 > 34 $ echo ${arr[@]} // 访问整个数组 ，@或者* 获取整个数组 > 123 34 3 5 $ echo ${#arr[@]} // 获取数组的长度（最大下标） ，#获取长度 数组中是最后一个下标 > 3 $ echo ${#arr[3]} // 获取字符串长度 > 1 $ echo ${arr[@]:1:2} // [...]]]></description>
			<content:encoded><![CDATA[<p>发现shell中的数组使用方法<br />
fallseir &#8212; http://blog.fallseir.com/2008/10/array_in_shell/ </p>
<p>$ arr=(123 34 3 5)<br />
$ echo $arr // 默认获取第一个元素<br />
> 123<br />
$ echo ${arr[1]} // 通过下标访问<br />
> 34<br />
$ echo ${arr[@]}     // 访问整个数组 ，@或者* 获取整个数组<br />
> 123 34 3 5<br />
$ echo ${#arr[@]}   // 获取数组的长度（最大下标） ，#获取长度 数组中是最后一个下标<br />
> 3<br />
$ echo ${#arr[3]}   // 获取字符串长度<br />
> 1<br />
$ echo ${arr[@]:1:2} // 切片方式获取一部分数组内容<br />
> 34 3<br />
$ echo ${arr[@]:2} // 从第二个元素开始<br />
> 3 5<br />
$ echo ${arr[@]::2} // 到第二个元素<br />
> 123 34</p>
<p>参考 http://www.tech-recipes.com/rx/642/bash-shell-script-accessing-array-variables/</p>
<p>array 的模拟操作<br />
&#8211; http://www.tech-recipes.com/rx/911/queue-and-stack-using-array/<br />
push:<br />
array=(”${array[@]}” $new_element)</p>
<p>pop:<br />
array=(${array[@]:0:$((${#array[@]}-1))})</p>
<p>shift:<br />
array=(${array[@]:1})</p>
<p>unshift<br />
array=($new_element “${array[@]}”)</p>
<p>function del_array {<br />
local i<br />
for (( i = 0 ; i < ${#array[@]} ; i++ ))<br />
do<br />
if [ "$1" = "${array[$i]}&#8221; ] ;then<br />
break<br />
fi<br />
done<br />
del_array_index $i<br />
}</p>
<p>function del_array_index {<br />
array=(${array[@]:0:$1} ${array[@]:$(($1 + 1))})<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fallseir.com/2008/10/array_in_shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
