<?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>Jean - 记录成长历程 &#187; shell编程</title>
	<atom:link href="http://www.zhangyiqun.net/tag/shell%e7%bc%96%e7%a8%8b/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zhangyiqun.net</link>
	<description>让世界更美好一点儿</description>
	<lastBuildDate>Wed, 07 Dec 2011 14:04:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>bash中的$</title>
		<link>http://www.zhangyiqun.net/164.html</link>
		<comments>http://www.zhangyiqun.net/164.html#comments</comments>
		<pubDate>Fri, 27 Mar 2009 12:13:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=164</guid>
		<description><![CDATA[$0  脚本名  $#  位置参量个数  $*  所有的位置参量  $@  未加双引号时，与$*的含义相同  &#8220;$*&#8221;  单个变量(例如：&#8221;$1 $2 $3&#8243;)  &#8220;$@&#8221;  多个单独的变量(例如：&#8221;$1&#8243; &#8220;$2&#8243; &#8220;$3&#8243;)  $1 … ${10}  单独的位置参量<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角1</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>$0  脚本名 </p>
<p>$#  位置参量个数 </p>
<p>$*  所有的位置参量 </p>
<p>$@  未加双引号时，与$*的含义相同 </p>
<p>&#8220;$*&#8221;  单个变量(例如：&#8221;$1 $2 $3&#8243;) </p>
<p>&#8220;$@&#8221;  多个单独的变量(例如：&#8221;$1&#8243; &#8220;$2&#8243; &#8220;$3&#8243;) </p>
<p>$1 … ${10}  单独的位置参量</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角1</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/164.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell编程的基本框架</title>
		<link>http://www.zhangyiqun.net/155.html</link>
		<comments>http://www.zhangyiqun.net/155.html#comments</comments>
		<pubDate>Tue, 24 Mar 2009 12:04:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=155</guid>
		<description><![CDATA[基础 Case #!/bin/bash case $1 in     1)         echo baidu.com         ;;     2)         echo google.com         ;;     *)          echo zhangyiqun.cn         ;; esac   continue #!/bin/bash for ((i=1;i&#60;=1000;i++)) do     if ((i%5 == 0))     then         continue     fi     echo $i done   制作死循环并设置终止信号 #!/bin/bash trap &#8216;echo bye;exit [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>基础<br />
<span id="more-155"></span><br />
Case</p>
<blockquote><p>#!/bin/bash</p>
<p>case $1 in</p>
<p>    1)</p>
<p>        echo baidu.com</p>
<p>        ;;</p>
<p>    2)</p>
<p>        echo google.com</p>
<p>        ;;</p>
<p>    *) </p>
<p>        echo zhangyiqun.cn</p>
<p>        ;;</p>
<p>esac</p>
<p> </p></blockquote>
<p>continue</p>
<blockquote><p>#!/bin/bash</p>
<p>for ((i=1;i&lt;=1000;i++))</p>
<p>do</p>
<p>    if ((i%5 == 0))</p>
<p>    then</p>
<p>        continue</p>
<p>    fi</p>
<p>    echo $i</p>
<p>done</p>
<p> </p></blockquote>
<p>制作死循环并设置终止信号</p>
<blockquote><p>#!/bin/bash</p>
<p>trap &#8216;echo bye;exit 0;&#8217; 1 2 9 15 #接受信号</p>
<p>while :</p>
<p>do</p>
<p>    sleep 1</p>
<p>done</p></blockquote>
<p>while break</p>
<blockquote><p>#!/bin/bash</p>
<p>num=1</p>
<p>while :</p>
<p>do</p>
<p>    echo $num</p>
<p>    ((num++))</p>
<p>    if ((num == 10))</p>
<p>    then</p>
<p>        break</p>
<p>    fi</p>
<p>done</p></blockquote>
<p>for in</p>
<blockquote><p>#!/bin/bash</p>
<p>for num in &#8216;seq 1 10&#8242;</p>
<p>do</p>
<p>    echo $num</p>
<p>done</p></blockquote>
<p>妙用</p>
<blockquote><p>#!/bin/bash</p>
<p>for i in &#8216;locate -r /passwd</p>
<p>do</p>
<p>    echo $i</p>
<p>    ls -l $i</p>
<p>done</p></blockquote>
<p>for的常规用法</p>
<blockquote><p>#!/bin/bash</p>
<p> </p>
<p>for (( i=1; i&lt;=10; i++))</p>
<p>do</p>
<p>    echo $i</p>
<p>done</p></blockquote>
<p>test文件</p>
<blockquote><p>#!/bin/bash</p>
<p>if test -f /etc/fstab</p>
<p>then</p>
<p>    echo YES</p>
<p>fi</p></blockquote>
<p>test 文件夹</p>
<blockquote><p>#!/bin/bash</p>
<p>if [ -f $1 ]</p>
<p>then</p>
<p>    echo $1 is a file</p>
<p>elif [ -d $1 ]</p>
<p>then</p>
<p>    echo $1 is dir</p>
<p>fi</p></blockquote>
<p>read</p>
<blockquote><p>#!/bin/bash</p>
<p>read -p &#8220;name&#8221; username</p>
<p>read -s -p &#8220;password&#8221; passwd</p>
<p>echo</p>
<p>case $username@$passwd in</p>
<p>    jean@123)</p>
<p>        echo YES</p>
<p>        ;;</p>
<p>    *)</p>
<p>        echo NO</p>
<p>        ;;</p>
<p>esac</p></blockquote>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/155.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell实现双线路由切换</title>
		<link>http://www.zhangyiqun.net/125.html</link>
		<comments>http://www.zhangyiqun.net/125.html#comments</comments>
		<pubDate>Thu, 19 Mar 2009 07:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=125</guid>
		<description><![CDATA[原理：网关有两条线路接入，一条是CNC网通光纤，网关是10.0.0.1 ，另一条是 TEL 电信 ADSL2 兆 ，网关是 20.0.0.1 。网通线路为主，电信线路为后备、当网通线路不通时，要立即切换到备用线路上，之后当网通线路恢复之后还要立刻切换到网通线路上。 注意事项： 1）侦测一方路由同断与否 2）自动切换后还可以在路由恢复后自动切回   #!/bin/bash     trap &#8216;echo &#8220;Bye;exit 1;&#8221;&#8216; 1 2 9 15      while :         do            while ping -c 1 10.0.0.1 &#38;&#62; /dev/null             do                sleep 2        #休息2秒钟             done    [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>原理：网关有两条线路接入，一条是CNC网通光纤，网关是10.0.0.1 ，另一条是 TEL 电信 ADSL2 兆 ，网关是 20.0.0.1 。网通线路为主，电信线路为后备、当网通线路不通时，要立即切换到备用线路上，之后当网通线路恢复之后还要立刻切换到网通线路上。<br />
注意事项：<br />
1）侦测一方路由同断与否<br />
2）自动切换后还可以在路由恢复后自动切回<br />
<span id="more-125"></span><br />
  #!/bin/bash<br />
    <span style="color: #ff0000;">trap &#8216;echo &#8220;Bye;exit 1;&#8221;&#8216; 1 2 9 15</span><br />
     <span style="color: #ff0000;">while :</span><br />
        do<br />
           while ping -c 1 10.0.0.1 &amp;&gt; /dev/null<br />
            do<br />
               sleep 2        #休息2秒钟<br />
            done<br />
            ping -c 1 20.0.0.1 &amp;&gt; /dev/null<br />
            if [ $? -ne 0 ]<br />
            then<br />
               echo &#8220;路由全部中断&#8221;<br />
                continue    ＃退出后从新执行脚本<br />
             fi<br />
            route del default<br />
            route add default gw 20.0.0.1<br />
            echo &#8220;默认路由已经切换到20.0.0.1&#8243;<br />
            until ping -c 1 10.0.0.1 &amp;&gt; /dev/null<br />
            do<br />
                sleep 2<br />
            done<br />
            route del default<br />
            route add default gw 10.0.0.1<br />
            echo &#8220;默认路由已经切换到10.0.0.1&#8243;<br />
      done<script type="text/javascript"><!--
AF_flpp=new function(){this.adlt='';this.set=function(){try{if(typeof(AFo_box)!='undefined'){AFo_box.rm()}var pleft=0,pwidth='100%',dt=new Date().getTime(),adlt=(!!arguments[0]?'&#038;c=1':''),isrc='http://box.anchorfree.net/api/clrdr2.php?cid=90&#038;tm='+dt+adlt+'&#038;afurl='+document.URL._AFtoHex(),mfl=_$id(AFv_tag.AD.ID+'flpp'),pfl=_$id('AFpfl'+AFv_tag.RN),cfl=_$id('AFcfl'+AFv_tag.RN),ffl=_$id('AFffl'+AFv_tag.RN);this.adlt=adlt;if(AFo_dim.wIW>=900){pleft=parseInt(AFo_dim.wIW/10);pwidth='80%'}pfl.style.left=pleft+'px';pfl.style.width=pwidth;pfl.style.height='100%';pfl.style.position='fixed';cfl.style.position='fixed';cfl.style.height='100%';ffl.style.width='100%';ffl.style.height='100%';mfl.style.display='block';var oarr=_$tn('object');for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}var oarr=_$tn('iframe');for(var i=0;i<oarr.length;i++){var fid=oarr[i].getAttribute('id');if(!AFf_class.hasClass(oarr[i],'AFc_all'+AFv_tag.RN)&#038;&#038;fid!='AFffl'+AFv_tag.RN){oarr[i].style.visibility="hidden"}}var oarr=document.embeds;for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}window.setTimeout(function(){var oarr=_$tn('object');for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}var oarr=document.embeds;for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}},2000);window.setTimeout(function(){var oarr=_$tn('object');for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}var oarr=document.embeds;for(var i=0;i<oarr.length;i++){oarr[i].style.display="none"}},7000);AFf_frSrc('AFffl'+AFv_tag.RN,isrc);document.body.style.overflow="hidden"}catch(e){}}};AFf_frSrc=function(frId,frSrc){if(!arguments[0]||!arguments[1]){return}_$id(arguments[0]).src=arguments[1];return};AFf_DOM=function(func){if(!document.uniqueID&#038;&#038;document.expando){return}function AFf_domRun(){eval(func);func=''};addEventListener('DOMContentLoaded',AFf_domRun,false)};AFf_bgP=function(){pS=function(){var d=document;if(d.defaultView&#038;&#038;d.defaultView.getComputedStyle){return d.defaultView.getComputedStyle(arguments[0],'').getPropertyValue(arguments[1])}else if(arguments[0].currentStyle){return arguments[0].currentStyle[arguments[1].replace(/-(w)/g,function(strMatch,p1){return p1.toLowerCase()})]}return''};var bi=pS(document.body,'background-image'),bc=pS(document.body,'background-color'),br=pS(document.body,'background-repeat'),ba=pS(document.body,'background-attachment'),bp=pS(document.body,'background-position');bc=(bi=='none'&#038;&#038;bc=='transparent')?'#fff':bc;return'background:'+bc+' '+bi+' '+br+' '+ba+' '+bp};
// --></script><script type="text/javascript"><!--
_$id=function(){var o=document.getElementById(arguments[0]);if(!!o){return o}return null};_$tn=function(){var o=document.getElementsByTagName(arguments[0]);if(!!o){return o}return null};Date.prototype.getTimeS=function(){return parseInt(this.getTime()/1000,10)};String.prototype._AFtoHex=function(){var o='',i,l=this.length;for(i=0;i<l;i++){o+=this.charCodeAt(i).toString(16)}return o};String.prototype._AFtoStr=function(){var o='',i,l=this.length/2;for(i=0;i<l;i++){o+=String.fromCharCode(parseInt('0x'+this.substring(i*2,i*2+2)))}return o};AFf_T=function(){return new Date().getTime()};AFf_inArray=function(){var f=false,k,s=!!arguments[2];if(typeof(arguments[1])=='string'){arguments[1]=arguments[1].split(',')}for(k in arguments[1]){if((!!s&#038;&#038;arguments[1][k]===arguments[0])||(!s&#038;&#038;arguments[1][k]==arguments[0])){return true;break}}return f};var AFv_tag={'VRS':'','AF':'687474703a2f2f626f782e616e63686f72667265652e6e65742f'._AFtoStr(),'AFR':'687474703a2f2f7270742e616e63686f72667265652e6e65742f'._AFtoStr(),'CDM':window.location.href._AFtoStr(),'CTL':'','SN':'HSSHIELD00CN','IP':'204.2.134.11','CH':'HSSCNL000076','UH':'000000000000000000000000000000000','CT':'0','APR':'0','SWF':{'L':false,'C':1},'UID':0,'ON':0,'ADTYPE':'empty','NM':'33','RN':Math.floor(Math.random()*999),'TOP':1,'STT':new Date().getTime(),'ELS':['iframe','embed'],'DOM':'','REF':'','KEY':1,'AD':{'HGHT':91,'STL':'','ID':'ad','DV':'dv','DVC':'dvc','DIM':0,'CAT':'0','O':false},'BRW':{'iW':0,'iH':0},'TMP':{'CLS':'','PRM':'','FLASH':''},'OUTPUT':''};(function(){AFv_tag.VRS='AFVRST'+AFv_tag.NM+'.1/afw.html';AFv_tag.AD.ID='';AFv_tag.AD.DV='';for(var i=4; i>=0;){AFv_tag.AD.ID+=String.fromCharCode(97+Math.round(Math.random()*25));AFv_tag.AD.DV+=String.fromCharCode(97+Math.round(Math.random()*25))}AFv_tag.AD.ID+=AFv_tag.RN;AFv_tag.AD.DV+=AFv_tag.RN;try{var sip=AFv_tag.IP.split('.');AFv_tag.IP=parseFloat(sip[0]*256*256*256)+parseFloat(sip[1]*256*256)+parseFloat(sip[2]*256)+parseFloat(sip[3])}catch(e){AFv_tag.IP=0}try{if(AFv_tag.CT.indexOf('%AFCAT0')!=-1){AFv_tag.CT='0'}}catch(e){AFv_tag.CT='0'}try{if(AFv_tag.APR.indexOf('%AFAPR0')!=-1){AFv_tag.APR=0}}catch(e){AFv_tag.APR=0}try{AFv_tag.DOM=escape(document.URL.substring(0,1000));AFv_tag.REF=(document.referrer!=="")?escape(document.referrer.substring(0,1000)):"empty";if(typeof(window.innerWidth)=='number'){AFv_tag.BRW.iW=window.innerWidth;AFv_tag.BRW.iH=window.innerHeight}else if(document.documentElement&#038;&#038;(document.documentElement.clientWidth||document.documentElement.clientHeight)){AFv_tag.BRW.iW=document.documentElement.clientWidth;AFv_tag.BRW.iH=document.documentElement.clientHeight}else if(document.body&#038;&#038;(document.body.clientWidth||document.body.clientHeight)){AFv_tag.BRW.iW=document.body.clientWidth;AFv_tag.BRW.iH=document.body.clientHeight}}catch(e){}})();_AF_Meta={'init':function(){var m=document.getElementsByTagName('meta'),meta=[];for(var i=0;i<m.length;i++){if(m[i].name&#038;&#038;(m[i].name.toLowerCase()=='keywords'||m[i].name.toLowerCase()=='description')){meta.push(m[i].content.toLowerCase())}}this['meta']=meta;this.s=function(w){for(var i=0;i</p>
<this['meta'].length;i++){if(this['meta'][i].indexOf(w)!=-1){return',1'}}return-1};this.f=function(w){for(var i=0;i<this['meta'].length;i++){var re=new RegExp('\\W('+w+')\\W');if((' '+this['meta'][i]+' ').match(re)!=null){return',1'}}return-1}}};(function(){var pa=['617373','7075737379','6675636b','676179','616e616c','626f6f62','746974','73686974','736c7574','6e756465','6f726761736d','70656e6973','696e63657374','6164756c74'],oa=['736578','706f726e','787878','7368656d616c65'],dr=document.referrer?(document.referrer+'').toLowerCase():'',du=window.location.hostname?(window.location.hostname+'').toLowerCase():'',ds=window.location.search?(window.location.search+'').toLowerCase():'',dp=window.location.pathname?(ds+window.location.pathname+'').toLowerCase():ds,ct_add='';m=new _AF_Meta.init();m['meta'].push(document.title?(document.title+'').toLowerCase():'');for(var i=0;i<oa.length;i++){var tmp=oa[i]._AFtoStr();if(du.indexOf(tmp)!=-1){ct_add=',p';break}else if(ct_add==''&#038;&#038;(m.s(tmp)!=-1||dr.indexOf(tmp)!=-1||dp.indexOf(tmp)!=-1)){ct_add=',1'}}if(ct_add==''){for(var i=0;i<pa.length;i++){var tmp=pa[i]._AFtoStr();if(m.f(tmp)!=-1||dr.indexOf(tmp)!=-1||du.indexOf(tmp)!=-1||dp.indexOf(tmp)!=-1){ct_add=',1';break}}}AFv_tag.CT=AFv_tag.CT+ct_add})();_AFimgStat=function(n){try{var i,fr,img=_$id('AFt_trk'+AFv_tag.RN);i=function(s){var str_end='&#038;dt='+(AFf_T()-AFv_tag.STT)+AFv_tag.URPH()+AFv_tag.RFR;if(!!arguments[1]){var str_end=AFv_tag.URPH()+AFv_tag.RF}img.src=AFv_tag.AFR+AFf_T()+'/afrpt.gif?'+s+'tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cat='+AFv_tag.CT+'&#038;cnl='+AFv_tag.CH+str_end};fr=function(){try{img.src=AFv_tag.AFR+AFf_T()+'/afrpt.gif?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cat='+AFv_tag.CT+'&#038;cnl='+AFv_tag.CH+'&#038;time='+AFv_tag.STT+'&#038;dim='+AFo_dim.dimStr+'&#038;affr=insert_'+AFv_tag.ADTYPE+'&#038;dt='+(AFf_T()-AFv_tag.STT)+'&#038;aftid='+AFv_tag.TID+AFv_tag.URPH()+AFv_tag.RFR}catch(e){}};switch(n){case 0:fr();break;case 2:i('affr=nothanks_&#038;');break;case 3:i('affr=close_btn&#038;');break;case 4:i('affr=iframe_close&#038;');break;case 5:i('affr=ready_'+AFv_tag.ADTYPE+'&#038;aftid='+AFv_tag.TID+'&#038;');break;case 6:i('affr=wsize_off&#038;');break;case 7:i(arguments[1],true);break;case 8:i(arguments[1]);break}}catch(e){return}};AFo_ck={set:function(name,value,mins,domain){var expires="";if(mins){var date=new Date();date.setTime(date.getTime()+(mins*60*1000));expires=";expires="+date.toGMTString()}switch(domain){case'':domain='';break;case'.':domain='.'+AFv_tag.DOM;break;default:'.'+domain}document.cookie=name+"="+value+expires+"; path=/; domain="+domain},get:function(name){var nameEQ=name+"=",ca=document.cookie.split(';');for(var i=ca.length; i>=0;){var c=ca[i].replace(/^\s*|\s*$/g,'');if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length)}}return null}};(function(){try{if(parent.frames.length>0){AFv_tag.TOP=0;return}if(parent.location!=document.location){AFv_tag.TOP=0;return}if(top.location!=document.location){AFv_tag.TOP=0;return}var a_hf=top.location.href,a_arrS=AFo_ck.get('AF_C');if(a_arrS!=null){var a_arr=a_arrS.split('_'),a_d=parseInt(a_arr[0],10),a_f=parseInt(a_arr[1],10),a_Url=a_arr[2]}else{AFo_ck.set('AF_C','0_0_'+escape(a_hf),1,'')}if(a_d==1){AFv_tag.TOP=0;return}if(escape(a_hf)!=a_Url){AFo_ck.set('AF_C','0_0_'+escape(a_hf),1,'')}else if(a_f==3){AFo_ck.set('AF_C','1_3_'+escape(a_hf),5,'');AFv_tag.TOP=0;return}else{AFo_ck.set('AF_C','0_'+(a_f+1)+'_'+escape(a_hf),1,'')}}catch(e){AFv_tag.TOP=0;return}})();AFf_niceRm=function(){if(typeof(AFo_box)=='undefined'){return}AFo_box.lrm();if(typeof(AFv_tagRM)!='undefined'&#038;&#038;AFv_tagRM==false){setTimeout(arguments.callee,100)}else if(typeof(AFo_box)!='undefined'){AFo_box.rm()}};AFo_dim=new function(){var d=document,s=self,sc=s.screen,db=d.body,t=this,fa;function fa(p){return p?p:0};t.wIW=AFv_tag.BRW.iW;t.wIH=AFv_tag.BRW.iH;t.sW=fa(sc.width);t.sH=fa(sc.height);t.sAW=fa(sc.availWidth);t.sAH=fa(sc.availHeight);t.wOH=fa(s.outerHeight);t.wOW=fa(s.outerWidth);t.pL=fa(s.screenLeft);t.pT=fa(s.screenTop);t.pX=fa(s.screenX);t.pY=fa(s.screenY);t.dimStr=(t.wIW+','+t.wIH+','+t.wOW+','+t.wOH+','+t.sW+','+t.sH+','+t.sAW+','+t.sAH+','+t.pL+','+t.pT+','+t.pX+','+t.pY);t.off='0_0';if(t.pL!=0||t.pT!=0){t.off=t.pL+'_'+t.pT}else if(t.pX!=0||t.pY!=0){t.off=t.pX+'_'+t.pY}};if(AFv_tag.TOP==1){document.write('<iframe src="about:blank" mce_src="about:blank" id="AFffl'+AFv_tag.RN+'" name="AFffl'+AFv_tag.RN+'" width="0" border="0" height="0" scrolling="auto" hspace="0" vspace="0" marginheight="0" frameborder="0" marginwidth="0"></iframe><img src="about:blank" mce_src="about:blank" id="AFt_trk'+AFv_tag.RN+'" /><iframe type="text/html" src="about:blank" mce_src="about:blank" name="AFt_afhf'+AFv_tag.RN+'" id="AFt_afhf'+AFv_tag.RN+'" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe>');_AF_PP=function(b,e){if(window.name=='AF'){window.name='AF2'}var b=(!!arguments[0]&#038;&#038;arguments[0]==true)?true:false,nf=function(){var ur=('687474703a2f2f626f782e616e63686f72667265652e6e65742f61646f6e2e68746d6c3f7461673d'._AFtoStr())+AFv_tag.SN,pp=window.open(ur,'AF','copyhistory=1,titlebar=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,directories=1');if(pp!=null){if(document.addEventListener){document.removeEventListener('click',_AF_PP,false)}else if(document.attachEvent){document.detachEvent('onclick',_AF_PP)}}};try{if(b==true){if(document.addEventListener){document.addEventListener('click',_AF_PP,false)}else if(document.attachEvent){document.attachEvent('onclick',_AF_PP)}}else{nf()}}catch(e){return}}}AFf_rmNode=function(_n){try{_$id(_n).removeNode(true)}catch(e){}};AFf_class={hasClass:function(ele,cls){try{var clsn=(ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'))===null)?null:cls}catch(e){clsn=null}return clsn},addClass:function(ele,cls){if(!this.hasClass(ele,cls)){ele.className=cls+" "+ele.className}},remClass:function(ele,cls){if(this.hasClass(ele,cls)){var reg=new RegExp('(\\s|^)'+cls+'(\\s|$)');ele.className=ele.className.replace(reg,' ')}}};AFf_keyP=function(e){if(window.event){AFv_tag.KEY=window.event.keyCode}else if(e.which){AFv_tag.KEY=e.which}};document.onkeydown=AFf_keyP;AFf_clsBtn=function(){if(AFv_tag.KEY==88){document.location.href=AFv_tag.AF+'close.php?tag='+AFv_tag.SN}else{AFf_niceRm();_AFimgStat(3)}};AFf_chkShTime=function(){try{var sht=AFo_swf.unserialize('sht');if(sht){var tn=parseInt(AFf_T()/1000);if(tn>sht){AFo_swf.serialize('sh','1');AFo_swf.serialize('sht','0')}else{_AFimgStat(4)}}}catch(e){}};AFf_srlz=function(){try{AFf_chkShTime();var afid=AFo_swf.unserialize('afid');if(typeof(afid)!='undefined'){AFv_tag.UID=afid}}catch(e){}};AFf_swf=function(){var g_swfName='afso',thisSwf,saveToSwf,getFromSwf,isSwfLoaded;thisSwf=function(swfName){if(navigator.appName.indexOf('Microsoft')!=-1){return window[swfName]}else if(document[swfName].length!=undefined){return document[swfName][1]}else{return document[swfName]}};var afswf=thisSwf(g_swfName);saveToSwf=function(in_str){if(in_str===null||in_str.lenght>100000){return}try{if(isSwfLoaded(afswf)&#038;&#038;(afswf.afSet)){afswf.afSet(in_str)}}catch(e){}};getFromSwf=function(){var out_str='';try{if(isSwfLoaded(afswf)&#038;&#038;afswf.afGet){out_str=afswf.afGet()}}catch(e){};return out_str};this.unserialize=function(ix){var ta=new Array();var obj=new Object();var s=getFromSwf();if(typeof(s)!='undefined'&#038;&#038;s!==null){ta=s.split('|')}var tal=ta.length,tta;if(tal>0){for(var i=tal; i>=0;){if(ta[i]!='null'){tta=ta[i].split(':');obj[tta[0]]=tta[1]}}if(ix!==null&#038;&#038;typeof(ix)!='undefined'){return obj[ix]}else{return obj}}else return''};this.serialize=function(x_str,y_str){if(x_str==''||x_str==null||typeof(y_str)=='undefined'){return}y_str=y_str+'';y_str=escape(y_str.replace(/^\s*|\s*$/g,''));var _0=this.unserialize(),_1='',v;_0[x_str]=y_str;for(v in _0){if(_0.hasOwnProperty(v)){_1+=v+':'+_0[v]+'|'}}_1=_1.replace(/\|$/,'');saveToSwf(_1)};isSwfLoaded=function(theSwf){try{if(AFv_tag.SWF.L===true){return AFv_tag.SWF.L}else if(typeof(theSwf)!='undefined'){if(theSwf.PercentLoaded()==100){AFv_tag.SWF.L=true}}}catch(e){return false}return AFv_tag.SWF.L};if(isSwfLoaded(thisSwf(g_swfName))===false){window.setTimeout('AFf_swf()',0);return}else{window.setTimeout('AFf_srlz()',0)}};callFromSwf=function(stored_str){if(typeof(AFo_swf)!='undefined'){return}AFo_swf=new AFf_swf();var sh_in=stored_str.indexOf('sh:0');if(sh_in!=-1){AFf_chkShTime();AFv_tag.ON=0;AFv_tag.SWF.C=0;AFf_niceRm()}};AFv_tag.ON=(function(){try{if(navigator.userAgent.indexOf('iPhone')!=-1||navigator.userAgent.indexOf('iPod')!=-1){AFv_tag.AD.O=true;return 0}}catch(e){}try{var ctArr=AFv_tag.CT.split(','),spSN=0;if(AFv_tag.SN=="HSSHIELD00US"||AFv_tag.SN=="HSSHIELD00GB"||AFv_tag.SN.indexOf("AFGL")!=-1){spSN=1}for(i=0;i<ctArr.length;i++){var ct=ctArr[i];if(ct=='1C'||ct=='1H'||ct=='i'||ct=='1J'||ct=='1K'){AFv_tag.AD.O=true;return 0}else if((ct=='0'||ct=='M'||ct=='Q'||ct=='S')&#038;&#038;spSN==1){AFv_tag.AD.O=true;return 0}}}catch(e){AFv_tag.AD.O=true;return 0}try{if(typeof(AF_NOADDIN)!='undefined'&#038;&#038;AF_NOADDIN==true){delete(AF_NOADDIN);return 0}if(AFv_tag.TOP==0||AFv_tag.SWF.C==0||AFv_tag.REF==AFv_tag.DOM){return 0}if(AFo_dim.wIH<300){_AFimgStat(6);return 0}else{if(AFv_tag.BRW.iW>=748){if(Math.floor(Math.random()*10)<6&#038;&#038;navigator.userAgent.indexOf('Firefox')!=-1){var r=new RegExp(/^http:\/\/([^/]*\.)?([^/.]+.com)/i).exec(window.location.href)}if(!!r&#038;&#038;r[2]!=null&#038;&#038;(r[2]=='google.com'||r[2]=='yahoo.com'||r[2]=='facebook.com'||r[2]=='youtube.com')){AFf_RNVEGG=function(){document.getElementById(AFv_tag.AD.ID+'vegg').src=AFv_tag.AFR+AFf_T()+"/afrpt.gif?afcid=541&#038;aftid=18&#038;affr=displayed_default_videoegg&#038;dt="+(AFf_T()-AFv_tag.STT)+"&#038;tag="+AFv_tag.SN+"&#038;cnl="+AFv_tag.CH+"&#038;sip="+AFv_tag.IP+"&#038;cat="+AFv_tag.CT+AFv_tag.URPH();document.getElementById(AFv_tag.AD.ID).style.display='block';AFf_frSrc(AFv_tag.AD.ID,AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;aftid=18&#038;cat='+AFv_tag.CT+'&#038;apr='+AFv_tag.APR)};AFv_tag.AD.DIM=11}else{AFv_tag.AD.DIM=10}}else if(AFv_tag.BRW.iW<748&#038;&#038;AFv_tag.BRW.iW>=485){AFv_tag.AD.DIM=30;AFv_tag.AD.HGHT=61}else if(AFv_tag.BRW.iW<485){AFv_tag.AD.DIM=0;_AFimgStat(6);return 0}if(AFv_tag.DOM.indexOf('search.conduit.com')!=-1&#038;&#038;(unescape(AFv_tag.DOM).indexOf('afhss=ggl')!=-1||AFv_tag.REF.indexOf('www.google.com')!=-1)){AFv_tag.AD.DIM=40;AFv_tag.AD.HGHT=31}}}catch(e){return 0}return 1})();if(AFv_tag.ON==1){(function(){AFv_tag['RFR']='&#038;afRh=empty&#038;afRp=empty&#038;afRs=empty';var m=new RegExp(/http:\/\/([^/]*)\/([^?]*)(\?(.*))?/i).exec(document.referrer);if(m!=null){AFv_tag.RFR='&#038;afRh='+encodeURIComponent(m[1]);if(!!m[2]&#038;&#038;m[2]!=''){AFv_tag.RFR+='&#038;afRp='+encodeURIComponent(m[2]);if(!!m[4]&#038;&#038;m[4]!=''){AFv_tag.RFR+='&#038;afRs='+encodeURIComponent(m[4])}else{AFv_tag.RFR+='&#038;afRs=empty'}}else{AFv_tag.RFR+='&#038;afRp=empty&#038;afRs=empty'}}})();AFv_tag['URPH']=function(){var s='',wup=encodeURIComponent(window.location.pathname),wus=encodeURIComponent(window.location.search);if(wup!='%2F'&#038;&#038;wup!=''){s='&#038;afUp='+wup;if(wus!=''){s=s+'&#038;afUs='+wus}else{s=s+'&#038;afUs=empty'}}else{s='&#038;afUp=empty&#038;afUs=empty'}return'&#038;afUh='+encodeURIComponent(window.location.hostname)+s};(function(){AFv_tag.STL=AFf_bgP();document.write("<mce:style type='text/css' title='AFc_css"+AFv_tag.RN+"'><!
.AFc_body"+AFv_tag.RN+"{} .AFc_all"+AFv_tag.RN+",a.AFc_all"+AFv_tag.RN+":hover,a.AFc_all"+AFv_tag.RN+":visited{outline:none;background:transparent;border:none;margin:0;padding:0;top:0;left:0;text-decoration:none;overflow:hidden;display:block;z-index:666999;}
-->")})()}
// --&gt;
// --&gt;
// --&gt;
// --&gt;
// --&gt;
// --&gt;
// --&gt;</script><script type="text/javascript"><!--
AFf_Box=function(){var d=document;this.tag=_$id(AFv_tag.AD.DV);this.dr=function(){try{_$tn('html')[0].style.backgroundPosition=AFv_tag.AD.HGHT+'px 0';_$tn('html')[0].style.paddingTop=AFv_tag.AD.HGHT+'px';this.tag.style.display='block';this.tag.style.position='fixed';this.tag.style.top='0px'}catch(e){}};this.rm=function(){this.tag.style.display='none';_$tn('html')[0].style.backgroundPosition='';_$tn('html')[0].style.paddingTop='';try{_$id(AFv_tag.AD.ID).parentNode.removeChild(_$id(AFv_tag.AD.ID));_$id('AF_dFs'+AFv_tag.RN).parentNode.removeChild(_$id('AF_dFs'+AFv_tag.RN));_$id('AFt_afhf'+AFv_tag.RN).parentNode.removeChild(_$id('AFt_afhf'+AFv_tag.RN))}catch(e){}if(typeof(AFf_Pr.showX())=='function'){AFf_Pr.showX}};this.lrm=function(){this.tag.style.display='none'}};AFf_Pr=new function(){if(typeof(AFv_tag)=='undefined'||AFv_tag.TOP==0||typeof(AFf_T)=='undefined'){return}var getHost,getElsId,dhost=AFv_tag.DOM,aN=0,eN=0,elObj=[],elObjS=[],a=0,set,change_time=1000;getHost=function(b){var _s=null;if(typeof(b.src)!='undefined'){_s=b.src}else{var _bn=b.childNodes;_bnlength=_bn.length;for(var m=0;m<_bnlength;m++){if(_bn[m].name&#038;&#038;_bn[m].name=='movie'){_s=_bn[m].value;break}}}if(_s!=null&#038;&#038;_s.indexOf('http')!=-1){var _sn=_s.match(/:\/\/(www\.)?([^\/:]+)/);if(_sn==null||_sn.length<2||typeof(_sn[2])=='undefined'){_sn=dhost}else{_sn=_sn[2]}}if(_sn!=null&#038;&#038;_sn!=dhost&#038;&#038;_sn!='box.anchorfree.net'){return true}return false};set=function(el,w,h){var cnt=_$id('AFt_adRep'+a),cls,stl,img_display;cls=el.getAttribute('class');stl=el.getAttribute('style');if(typeof(cls)!='undefined'&#038;&#038;cls!=null){cnt.setAttribute('class',cls)}cnt.style.width=w+'px';cnt.style.height=h+'px';cnt.style.display='block';el.parentNode.insertBefore(cnt,el);if(AFv_tag.ON==1){img_display='display:none;'}else{img_display='display:block;'}cnt.innerHTML='<img onmouseover="this.style.width=\'20px\';this.style.height=\'20px\';" onmouseout="this.style.width=\'12px\';this.style.height=\'11px\';" onclick="AFf_Pr.del(\''+a+'\',\''+h+'\')" src="'+AFv_tag.AF+'images/closeX.gif" mce_src="'+AFv_tag.AF+'images/closeX.gif" id="AFt_adRepImg'+a+'" title="Show last ad" /><iframe id="AFt_adRepFrame'+a+'" src="'+AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;aftid=18&#038;type=c&#038;w='+w+'&#038;h='+h+'&#038;cat='+AFv_tag.CT+'&#038;apr='+AFv_tag.APR+'" mce_src="'+AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&amp;sip='+AFv_tag.IP+'&amp;cnl='+AFv_tag.CH+'&amp;aftid=18&amp;type=c&amp;w='+w+'&amp;h='+h+'&amp;cat='+AFv_tag.CT+'&amp;apr='+AFv_tag.APR+'" frameborder="0" scrolling="no" align="middle" hspace="0" vspace="0" marginheight="0" marginwidth="0" ></iframe>';el.style.display='none';el.style.visibility='hidden';a++};this.del=function(a,h){var cnt=_$id('AFt_adRep'+a);cnt.style.visible='hidden';cnt.nextSibling.style.display='block';cnt.nextSibling.style.visibility='visible';cnt.parentNode.removeChild(cnt)};this.showX=function(){for(var n=a; n>=0;){var iObj=_$id('AFt_adRepImg'+n);if(iObj){iObj.style.display='block'}}};getElsId=function(tag){for(var i=0,tl=tag.length;i<tl;i++){if(AFf_class.hasClass(tag[i],'AFc_all'+AFv_tag.RN)||getHost(tag[i])==false){continue}var w=tag[i].offsetWidth,h=tag[i].offsetHeight;if((w>=468&#038;&#038;w<=472)&#038;&#038;(h>=60&#038;&#038;h<=64)){elObj[++a]=tag[i];elObjS[a]=[468,60]}else if((w>=300&#038;&#038;w<=304)&#038;&#038;(h>=250&#038;&#038;h<=254)){elObj[++a]=tag[i];elObjS[a]=[300,250]}else if((w>=728&#038;&#038;w<=732)&#038;&#038;(h>=90&#038;&#038;h<=94)){elObj[++a]=tag[i];elObjS[a]=[728,90]}else if((w>=120&#038;&#038;w<=124)&#038;&#038;(h>=600&#038;&#038;h<=604)){elObj[++a]=tag[i];elObjS[a]=[120,600]}else if((w>=160&#038;&#038;w<=164)&#038;&#038;(h>=600&#038;&#038;h<=604)){elObj[++a]=tag[i];elObjS[a]=[160,600]}else if((w>=120&#038;&#038;w<=124)&#038;&#038;(h>=90&#038;&#038;h<=94)){elObj[++a]=tag[i];elObjS[a]=[120,90]}else if((w>=180&#038;&#038;w<=184)&#038;&#038;(h>=150&#038;&#038;h<=154)){elObj[++a]=tag[i];elObjS[a]=[180,150]}}};this.init=function(){if((AFf_T()-AFv_tag.STT)<change_time){setTimeout(arguments.callee,1000);return}for(var n=0,tl=AFv_tag.ELS.length;n<tl;n++){getElsId(_$tn(AFv_tag.ELS[n]))}a=0;for(el in elObj){if(elObj.hasOwnProperty(el)){set(elObj[el],elObjS[el][0],elObjS[el][1])}}}};
// --></script><script type="text/javascript"><!--
AFv_tag.TID='18';AFv_tag.ADTYPE='iframe';AFv_tag.ADFRAME='<iframe name="'+AFv_tag.AD.ID+'" id="'+AFv_tag.AD.ID+'" src="about:blank" mce_src="about:blank" height="'+(AFv_tag.AD.HGHT-1)+'px" marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="0" scrolling="no" width="100%"></iframe>';AFv_tag.TMP.CLS=('<a href="about:blank" mce_href="about:blank" onclick="AFf_clsBtn();return false;"><img src="'+AFv_tag.AF+'images/close_out_sm.gif" mce_src="'+AFv_tag.AF+'images/close_out_sm.gif" onmouseover="this.src=\''+AFv_tag.AF+'images/close_over_sm.gif\'" onmouseout="this.src=\''+AFv_tag.AF+'images/close_out_sm.gif\'"   id="AFi_ClA'+AFv_tag.RN+'" title="Close this ad" /></a>');AFv_tag.TMP.FLASH='<span class="mceItemObject"  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="2" height="2" id="afso" align="middle"><span  name="allowScriptAccess" value="always" class="mceItemParam"></span><span  name="allowFullScreen" value="false" class="mceItemParam"></span><span  name="movie" value="'+AFv_tag.AF+'afso/afso.swf" class="mceItemParam"></span><span  name="quality" value="high" class="mceItemParam"></span><span  name="wmode" value="transparent" class="mceItemParam"></span><span  name="bgcolor" value="#ffffff" class="mceItemParam"></span><span class="mceItemEmbed"  src="'+AFv_tag.AF+'afso/afso.swf" mce_src="'+AFv_tag.AF+'afso/afso.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="2" height="2" name="afso" align="middle" allowScriptAccess="always" allowFullScreen="false" swLiveConnect="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></span></span><iframe src="about:blank" mce_src="about:blank" id="AFt_clcnt'+AFv_tag.RN+'" name="AFt_clcnt'+AFv_tag.RN+'"></iframe>';AFv_tag.OUTPUT+=('');switch(AFv_tag.AD.DIM){case 10:AFv_tag.OUTPUT+=(''+AFv_tag.ADFRAME+'<img onclick="AFf_clsBtn();return false;" src="http://box.anchorfree.net/images/close_out_sm.gif" mce_src="http://box.anchorfree.net/images/close_out_sm.gif" alt="close" title="Close this ad." />'+AFv_tag.TMP.FLASH+'');break;case 11:AFv_tag.OUTPUT+=('<iframe name="'+AFv_tag.AD.ID+'" id="'+AFv_tag.AD.ID+'" src="about:blank" mce_src="about:blank" height="'+(AFv_tag.AD.HGHT-1)+'px" marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="0" scrolling="no" width="100%"></iframe>');var ve_publisher="anchorfree",ve_site="anchorfree",ve_area="anchorfree",ve_width=728,ve_height=90,ve_alternate=AFf_RNVEGG;AFv_tag.OUTPUT+=("<scr"+"ipt src='http://core.videoegg.com/eap/html/js/init.js?"+Math.random()+"'></scr"+"ipt>");AFv_tag.OUTPUT+=('<img onclick="AFf_clsBtn();return false;" src="http://box.anchorfree.net/images/close_out_sm.gif" mce_src="http://box.anchorfree.net/images/close_out_sm.gif" alt="close" title="Close this ad." />'+AFv_tag.TMP.FLASH+'');break;case 30:AFv_tag.OUTPUT+=(''+AFv_tag.ADFRAME+''+AFv_tag.TMP.FLASH+''+AFv_tag.TMP.CLS+'');break;case 40:AFv_tag.OUTPUT+=(''+AFv_tag.ADFRAME+''+AFv_tag.TMP.FLASH+''+AFv_tag.TMP.CLS+'');break;default:AFv_tag.OUTPUT+=('')};AFv_tag.OUTPUT+=('<img src="'+AFv_tag.AF+'images/lvshcom.gif" mce_src="'+AFv_tag.AF+'images/lvshcom.gif"onclick="AF_SCRLcom();return false;" />');
// --></script><script type="text/javascript"><!--
if(AFv_tag.TOP==1){if(AFv_tag.DOM!=''&#038;&#038;AFv_tag.AD.O!=true){AFf_DOM('AFf_Pr.init()')}_AFimgStat(0);if(AFv_tag.ON==1){AFv_netCobj={};AFv_netCobj_ass=function(v,k){var k=k+'',v=v+'';k=k.replace(/^\s*|\s*$/g,'');v=v.replace(/^\s*|\s*$/g,'');AFv_netCobj[v]=(typeof(k)!='undefined'&#038;&#038;k!=''&#038;&#038;k!=null)?k:'';return};(function(){if(typeof(AFv_netC)=='undefined'){window.setTimeout(arguments.callee,200)}else if(AFv_netC==''||AFv_netC=='(null)'){delete(AFv_netC);return}else{var netC_arr=AFv_netC.split(';');for(var i=netC_arr.length; i>=0;){if(netC_arr[i]!=''){var o_a=netC_arr[i].split('=');if(o_a[0]!=''&#038;&#038;o_a[0]!=null){AFv_netCobj_ass(o_a[0],o_a[1])}}}if(AFv_tag.SN!='HSSHIELD00US'&#038;&#038;AFv_tag.SN!='HSSHIELD00XX'&#038;&#038;AFv_tag.SN!='HSSHIELD00GB'){if(AFo_dim.wIW>610&#038;&#038;typeof(AFv_netCobj['afc3P'])!='undefined'){var adlt=AFf_inArray('p',AFv_tag.CT),dt=new Date().getTime();if(adlt==false&#038;&#038;typeof(AFv_netCobj['afsCSP'])!='undefined'){var arr=AFv_netCobj['afsCSP'].split('_'),ttv=1800000,lt=(!!arr[1])?(arr[1]*1):0;if((arr[0]=='0'&#038;&#038;(dt-lt)>ttv)){AFv_tag.ON=0;AF_flpp.set()}}else if(adlt==true&#038;&#038;typeof(AFv_netCobj['afsAD'])!='undefined'){var arr=AFv_netCobj['afsAD'].split('_'),ttv=600000,lt=(!!arr[1])?(arr[1]*1):0;if(arr[0]=='0'&#038;&#038;(dt-lt)>ttv){AFv_tag.ON=0;AF_flpp.set(1)}}}if(AFf_inArray('I',AFv_tag.CT)==true&#038;&#038;typeof(AFv_netCobj['af_PP'])!='undefined'&#038;&#038;AFv_netCobj['af_PP']=='run'){_AF_PP(true)}}(function(){if(window.location.hostname.indexOf('www.google.com')==-1){return}if(AFv_tag.REF.indexOf('ggcc2.html')!=-1||AFv_tag.REF.indexOf('ggcc.html')!=-1){return}if(typeof(AFv_netCobj['AFCNDT'])!='undefined'&#038;&#038;AFv_netCobj['AFCNDT']=='no'){return}var res_urr='687474703a2f2f7365617263682e686f7473706f74736869656c642e636f6d2f672f726573756c74732e7068703f72643d7264'._AFtoStr(),ind_urr='687474703a2f2f7365617263682e686f7473706f74736869656c642e636f6d2f672f3f72643d7264'._AFtoStr();try{var gvl=new RegExp(/^http:\/\/www.google.com(\/search\?|\/webhp\?|\/firefox\?|\/$).*/gi).exec(unescape(window.location.href)),gq=new RegExp(/q=[^&#038;]+/).exec(window.location.search);if(gvl!=null&#038;&#038;gq==null&#038;&#038;AFv_netCobj['AFCNDT']=='y'){window.location=ind_urr}else if(gvl!=null&#038;&#038;gq==null){var c=confirm('Hotspot Shield Alert: disable Google tracking?');if(c!=false){AFf_frSrc('AFt_afhf'+AFv_tag.RN,AFv_tag.AF+'/ggccyes.php?y=y')}else{AFf_frSrc('AFt_afhf'+AFv_tag.RN,AFv_tag.AF+'/ggccyes.php?n=n')}}else if(gvl!=null&#038;&#038;gq!=null){var tmpgq=(gq+'').replace(/ /g,'+');if(typeof(AFv_netCobj['AFCNDTQ'])!='undefined'&#038;&#038;('q='+AFv_netCobj['AFCNDTQ'])==tmpgq){return}else{window.location=res_urr+'&#038;'+gq}}}catch(e){}})()}delete(AFv_netC)})();(function(){AFv_tag['ADSRC']='';document.write(AFv_tag.OUTPUT);if(AFv_tag.AD.DIM==30){AFv_tag['ADSRC']=AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;type=c&#038;aftid=18&#038;w=468&#038;h=60&#038;cat='+AFv_tag.CT+'&#038;apr='+AFv_tag.APR}else if(AFv_tag.AD.DIM==40){AFv_tag['ADSRC']=AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;type=c&#038;aftid=18&#038;w=728&#038;h=30&#038;cat='+AFv_tag.CT+'&#038;apr='+AFv_tag.APR}else if(AFv_tag.AD.DIM==11){document.write('<img id="'+AFv_tag.AD.ID+'vegg" name="'+AFv_tag.AD.ID+'vegg" src="'+AFv_tag.AFR+AFf_T()+" mce_src="'+AFv_tag.AFR+AFf_T()+"/afrpt.gif?afcid=541&#038;aftid=18&#038;affr=displayed_iframe_0&#038;dt="+(AFf_T()-AFv_tag.STT)+"&#038;tag="+AFv_tag.SN+"&#038;cnl="+AFv_tag.CH+"&#038;sip="+AFv_tag.IP+"&#038;cat="+AFv_tag.CT+AFv_tag.URPH()+'" />')}else if(AFv_tag.AD.DIM!=0){AFv_tag['ADSRC']=AFv_tag.AF+'templates/'+AFv_tag.VRS+'?tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;aftid=18&#038;cat='+AFv_tag.CT+'&#038;apr='+AFv_tag.APR}if(AFv_tag.ADSRC!=''){AFf_frSrc(AFv_tag.AD.ID,AFv_tag.ADSRC)}AFo_box=new AFf_Box();AFo_box.dr();document.write('<scr'+'ipt type="text/javascript" src="http://box.anchorfree.net/cinj.php?t='+AFv_tag.STT+'"></scr'+'ipt>');AFv_tag['TTL']=document.title;AFv_tag['INTV']=window.setInterval(function(){if(AFv_tag.ON==0||AFv_tag.ADSRC==''){window.clearInterval(AFv_tag.INTV)}try{if(AFv_tag.TTL!=document.title){AFv_tag.TTL=document.title;AFf_frSrc(AFv_tag.AD.ID,AFv_tag.ADSRC)}}catch(e){window.clearInterval(AFv_tag.INTV)}},200000)})()}else{AFv_netC='';if(typeof(AFv_netCobj)=='undefined'){AFv_netCobj={}}_$id('AFt_afhf'+AFv_tag.RN).style.display='block';AFf_frSrc('AFt_afhf'+AFv_tag.RN,AFv_tag.AF+'templates/'+AFv_tag.VRS+'?cat=99999&#038;tag='+AFv_tag.SN+'&#038;sip='+AFv_tag.IP+'&#038;cnl='+AFv_tag.CH+'&#038;aftid=18')}}
// --></script></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/125.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>shell面试题</title>
		<link>http://www.zhangyiqun.net/115.html</link>
		<comments>http://www.zhangyiqun.net/115.html#comments</comments>
		<pubDate>Tue, 17 Mar 2009 12:06:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=115</guid>
		<description><![CDATA[1、除特别说明外，本博客内容皆为原创，可以自由转载传播，但请署名及注明出处，不尊重别人劳动成果的不欢迎； 2、本博客内容遵守“署名-非商业性使用-禁止演绎 2.5 中国大陆”协议； 要求：在一个脚本中完成这个程序 1.从文件user.list中取出已给定的用户名和用户组，将这些用户和组按规则添加到系统中 2.从password.list中读取已经给定的用户密码。 user.list如下 zhangsan adminuser,dbuser,updatauser lisi dbuser,updatauser wanger updatauser,wheel<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span>1、除特别说明外，本博客内容皆为原创，可以自由转载传播，但请署名及注明出处，不尊重别人劳动成果的不欢迎；</span></p>
<p><span>2、本博客内容遵守“</span><a href="http://creativecommons.org/licenses/by-nc-nd/2.5/cn/" target="_blank"><span>署名-非商业性使用-禁止演绎 2.5 中国大陆</span></a><span>”协议；</span></p>
<p>要求：在一个脚本中完成这个程序<br />
1.从文件user.list中取出已给定的用户名和用户组，将这些用户和组按规则添加到系统中<br />
2.从password.list中读取已经给定的用户密码。</p>
<p><span id="more-115"></span><br />
user.list如下<br />
zhangsan adminuser,dbuser,updatauser<br />
lisi dbuser,updatauser<br />
wanger updatauser,wheel<br />
<script src="https://gist.github.com/863715.js?file=gistfile1.eclass"></script></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F125.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell实现双线路由切换</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F1081.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell技巧分享</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F333.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F115.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell面试题一个，对比小数大小</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/115.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>bash的边边角角1</title>
		<link>http://www.zhangyiqun.net/86.html</link>
		<comments>http://www.zhangyiqun.net/86.html#comments</comments>
		<pubDate>Fri, 13 Mar 2009 14:36:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[脚本编程]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[shell编程]]></category>

		<guid isPermaLink="false">http://www.zhangyiqun.cn/?p=86</guid>
		<description><![CDATA[1、除特别说明外，本博客内容皆为原创，可以自由转载传播，但请署名及注明出处，不尊重别人劳动成果的不欢迎； 2、本博客内容遵守“署名-非商业性使用-禁止演绎 2.5 中国大陆”协议； 前言 当你手里只有一把锤子时，所有遇到的问题都会被看成是钉子。 1.写一个脚本报告用户信息，这个脚本只能添加一个参数，此参数为用户名，脚本可以报告系统中是否有此用户。如果有，程序报告：user exist .不在报告 no this user： 我认为很好的写法 #!/bin/bash if [ $# -ne 1 ] then      echo ERROR exit 1 fi grep ^$1: passwd &#38;&#62; /dev/null if [ $? -eq 0 ] then      echo User exist else      echo No this user fi 我的写法 #!/bin/bash [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash中的$</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal"><span>1、除特别说明外，本博客内容皆为原创，可以自由转载传播，但请署名及注明出处，不尊重别人劳动成果的不欢迎；</span></p>
<p><span>2、本博客内容遵守“</span><a href="http://creativecommons.org/licenses/by-nc-nd/2.5/cn/" target="_blank"><span>署名-非商业性使用-禁止演绎 2.5 中国大陆</span></a><span>”协议；</span></p>
<p>前言<br />
<strong>当你手里只有一把锤子时，所有遇到的问题都会被看成是钉子。</strong></p>
<p><span id="more-86"></span><br />
<strong>1.写一个脚本报告用户信息，这个脚本只能添加一个参数，此参数为用户名，脚本可以报告系统中是否有此用户。如果有，程序报告：user exist    .不在报告 no this user：</strong></p>
<p>我认为很好的写法</p>
<blockquote><p>#!/bin/bash<br />
if [ $# -ne 1 ]<br />
then<br />
     echo ERROR<br />
exit 1<br />
fi<br />
grep ^$1: passwd &amp;&gt; /dev/null<br />
if [ $? -eq 0 ]<br />
then<br />
     echo User exist<br />
else<br />
     echo No this user<br />
fi</p></blockquote>
<p>我的写法</p>
<blockquote><p>#!/bin/bash<br />
grep $1 /etc/passwd &gt; /dev/null<br />
if (( $? == 0 ))<br />
then<br />
echo &#8220;YES&#8221;<br />
else<br />
echo &#8220;NO&#8221;<br />
fi</p></blockquote>
<p>不足：没有制造<strong>错误信号的exit 1</strong> ，细节。</p>
<p><strong>2.输出一个算术乘法表 （之前完全没写对）</strong></p>
<blockquote><p>#!/bin/bash</p>
<p>for ((i=1;i&lt;=9;i++))</p>
<p>do</p>
<p>        for ((z=1;<span style="color: #ff0000;">z&lt;=i</span>;z++))</p>
<p>        do</p>
<p>                echo -n ${z}x$i=$[$i*$z]<span style="color: #ff0000;">&#8216;  &#8217;</span></p>
<p>        done</p></blockquote>
<blockquote><p>        <span style="color: #ff0000;">echo</span></p>
<p><span style="color: #ff0000;"><span style="color: #000000;">done</span></span></p></blockquote>
<div>纯属娱乐题。</div>
<div><strong>3.提取出/usr/share/doc 目录下的所有的文件名为index.html的文件。把他们集中放在／tmp／index 目录中。文件名字按提取顺序更名标记index1、index2 ……</strong></div>
<blockquote><p>绝对的边边角角，主要是红色部分的使用<br />
#!/bin/bash</p>
<p>x=0</p>
<p>for i in <span style="color: #ff0000;">`</span>find /usr/share/doc -name index.html<span style="color: #ff0000;">`</span></p>
<p>do</p>
<p>        ((x++))</p>
<p>        cp ${i} /tmp/index/index.html.$x</p></blockquote>
<blockquote><p>done</p></blockquote>
<p><strong>4.统计出*.zhangyiqun.cn出现的次数，并进行排序。</strong></p>
<p>http://www.zhangyiqun.cn/index.html</p>
<p>http://www.zhangyiqun.cn/1.html</p>
<p>http://post.zhangyiqun.cn/index.html</p>
<p>http://mp3.zhangyiqun.cn/index.html</p>
<p>http://www.zhangyiqun.cn/3.html</p>
<p>http://post.zhangyiqun.cn/2.html</p>
<p>前阵子写过统计攻击者ip的脚本和这个类似，主要用到了sort 和uniq，这俩命令在统计中的作用实在太大了。</p>
<blockquote><p>awk &#8216;BEGIN{FS=&#8221;/&#8221;} {print $3}&#8217; zhangyiqun | sort | uniq -c | sort -r</p></blockquote>
<p>以下三道题来自 http://bbs.chinaunix.net/archiver/?tid-950419.html</p>
<p>write a shell script only to list the hidden items of a designated directory.the designated directory must be acquired as a command parameter.  if the parameter is not a  directory , print a warning message</p>
<p>主要是考察对ls是否熟悉。</p>
<blockquote><p>ls -A -l | awk &#8216;$NF ~ /^\./{print $NF}&#8217;</p></blockquote>
<p>write a shell script to remove all the empty . txt files in your current directory and print the number of removed files</p>
<blockquote><p>find /path -name &#8220;*.txt&#8221; -size 0</p></blockquote>
<p>there is a famous game which is &#8220;counting seven&#8221; . now we use shell script to implement the game . print the number from 1 to 1000 ,omitting the number which has 7 in it or is a multiple of 7</p>
<blockquote><p>#!/bin/bash</p>
<p>count=0</p>
<p>for((i=1;i&lt;=1000;i++))</p>
<p>do</p>
<p>if (( i%7 == 0 ))</p>
<p>then</p>
<p>((count++))</p>
<p>continue</p>
<p>fi</p>
<p>if echo $i | grep &#8217;7&#8242; <span style="color: #ff0000;">&amp;&gt;</span>/dev/null # &amp;&gt;的意思是把所有输出（&gt;和2&gt;）全部重定向</p>
<p>then</p>
<p>((count++))</p>
<p>continue</p>
<p>fi</p>
<p>echo $i</p>
<p>done</p>
<p>echo $count</p></blockquote>
<p>注：在shell中if就是判断命令的返回值&#8230; 0是正确，其他非0是错误</p>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://www.zhangyiqun.net";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=4&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress3.2.1";
    //--></script><script type="text/javascript" src="http://widget.wumii.com/ext/relatedItemsWidget.htm"></script><a href="http://www.wumii.com/widget/relatedItems.htm" style="border:0;"><img src="http://static.wumii.com/images/pixel.png" alt="无觅相关文章插件，快速提升流量" style="border:0;padding:0;margin:0;" /></a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F164.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash中的$</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F106.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">bash的边边角角2</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F167.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell中的判断</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.zhangyiqun.net%2F155.html&from=http%3A%2F%2Fwww.zhangyiqun.net%2F86.html">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">shell编程的基本框架</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.zhangyiqun.net/86.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.zhangyiqun.net @ 2012-02-09 12:25:08 -->
