<?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>稀饭的国度 &#187; shell</title>
	<atom:link href="http://blog.thematice.com/html/ytag/shell/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.thematice.com</link>
	<description>发现自己的脑袋不好使了，用blog来记录真的很好用。</description>
	<lastBuildDate>Wed, 01 Feb 2012 05:33:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>sed1line_zh-CN</title>
		<link>http://blog.thematice.com/html/y2010/02/23/1035/sed1line_zh-cn.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sed1line_zh-cn</link>
		<comments>http://blog.thematice.com/html/y2010/02/23/1035/sed1line_zh-cn.html#comments</comments>
		<pubDate>Tue, 23 Feb 2010 02:13:11 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[sed&swk&shell]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=1035</guid>
		<description><![CDATA[?Download shell.sh1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2010/02/23/1035/sed1line_zh-cn.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Shell 快捷键的学习使用</title>
		<link>http://blog.thematice.com/html/y2009/12/27/932/bash-shell-%e5%bf%ab%e6%8d%b7%e9%94%ae%e7%9a%84%e5%ad%a6%e4%b9%a0%e4%bd%bf%e7%94%a8.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bash-shell-%25e5%25bf%25ab%25e6%258d%25b7%25e9%2594%25ae%25e7%259a%2584%25e5%25ad%25a6%25e4%25b9%25a0%25e4%25bd%25bf%25e7%2594%25a8</link>
		<comments>http://blog.thematice.com/html/y2009/12/27/932/bash-shell-%e5%bf%ab%e6%8d%b7%e9%94%ae%e7%9a%84%e5%ad%a6%e4%b9%a0%e4%bd%bf%e7%94%a8.html#comments</comments>
		<pubDate>Sun, 27 Dec 2009 12:47:51 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Shortcuts]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=932</guid>
		<description><![CDATA[这篇 Bash Shell Shortcuts 的快捷键总结的非常好。值得学习。下面内容大多数是拷贝粘贴与总结. CTRL 键相关的快捷键: Ctrl + a &#8211; Jump to the start of the line Ctrl + b &#8211; Move back a char Ctrl + c &#8211; Terminate the command //用的最多了吧? Ctrl + d &#8211; Delete from under the cursor Ctrl + e &#8211; Jump to the end of the line Ctrl [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/12/27/932/bash-shell-%e5%bf%ab%e6%8d%b7%e9%94%ae%e7%9a%84%e5%ad%a6%e4%b9%a0%e4%bd%bf%e7%94%a8.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>理解 Linux 的处理器负载均值（翻译）</title>
		<link>http://blog.thematice.com/html/y2009/12/18/923/understanding-of-the-processor-load-linux-average.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=understanding-of-the-processor-load-linux-average</link>
		<comments>http://blog.thematice.com/html/y2009/12/18/923/understanding-of-the-processor-load-linux-average.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:30:17 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[load Average]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=923</guid>
		<description><![CDATA[原文链接： http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages 你可能对于 Linux 的负载均值（load averages）已有了充分的了解。负载均值在 uptime 或者 top 命令中可以看到，它们可能会显示成这个样子： ?Download shell.sh1 load average: 0.09, 0.05, 0.01 很多人会这样理解负载均值：三个数分别代表不同时间段的系统平均负载（一分钟、五 分钟、以及十五分钟），它们的数字当然是越小越好。数字越高，说明服务器的负载越 大，这也可能是服务器出现某种问题的信号。 而事实不完全如此，是什么因素构成了负载均值的大小，以及如何区分它们目前的状况是 “好”还是“糟糕”？什么时候应该注意哪些不正常的数值？ 回答这些问题之前，首先需要了解下这些数值背后的些知识。我们先用最简单的例子说明， 一台只配备一块单核处理器的服务器。 行车过桥 一只单核的处理器可以形象得比喻成一条单车道。设想下，你现在需要收取这条道路的过桥 费 &#8212; 忙于处理那些将要过桥的车辆。你首先当然需要了解些信息，例如车辆的载重、以及 还有多少车辆正在等待过桥。如果前面没有车辆在等待，那么你可以告诉后面的司机通过。 如果车辆众多，那么需要告知他们可能需要稍等一会。 因此，需要些特定的代号表示目前的车流情况，例如： 0.00 表示目前桥面上没有任何的车流。 实际上这种情况与 0.00 和 1.00 之间是相同的，总而言之很通畅，过往的车辆可以丝毫不用等待的通过。 1.00 表示刚好是在这座桥的承受范围内。 这种情况不算糟糕，只是车流会有些堵，不过这种情况可能会造成交通越来越慢。 超过 1.00，那么说明这座桥已经超出负荷，交通严重的拥堵。 那么情况有多糟糕？ 例如 2.00 的情况说明车流已经超出了桥所能承受的一倍，那么将有多余过桥一倍的车辆正在焦急的等待。3.00 的话情况就更不妙了，说明这座桥基本上已经快承受不了，还有超出桥负载两倍多的车辆正在等待。 上面的情况和处理器的负载情况非常相似。一辆汽车的过桥时间就好比是处理器处理某线程 的实际时间。Unix 系统定义的进程运行时长为所有处理器内核的处理时间加上线程 在队列中等待的时间。 和收过桥费的管理员一样，你当然希望你的汽车（操作）不会被焦急的等待。所以，理想状态 下，都希望负载平均值小于 [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/12/18/923/understanding-of-the-processor-load-linux-average.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>理解Load Average做好压力测试</title>
		<link>http://blog.thematice.com/html/y2009/12/18/919/load-average-good-understanding-of-stress-testing.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=load-average-good-understanding-of-stress-testing</link>
		<comments>http://blog.thematice.com/html/y2009/12/18/919/load-average-good-understanding-of-stress-testing.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:27:08 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[configure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[load Average]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=919</guid>
		<description><![CDATA[最近刚接手的产品问题很多，主要是集中在产品设计和性能上，另外代码的可维护性也很差，这两周处理故障和问题的时间比较多，博客更新的也少了，下面的这篇文章是解释开发小组成员介绍并发编程的一些基本原理而收集到的一篇比较好的文章，作者以浅显易懂的方式介绍了比较复杂的概念。我觉得如果我们能够把一个复杂、抽象的概念如果能够通过生活中常见的场景来加以说明和描述出来，那么我们就真正理解了这个概念。 SIP的第四期结束了，因为控制策略的丰富，早先的的压力测试结果已经无法反映在高并发和高压力下SIP的运行状况，因此需要重新作压力测试。跟在测试人员后面做了快一周的压力测试，压力测试的报告也正式出炉，本来也就算是告一段落，但第二天测试人员说要修改报告，由于这次作压力测试的同学是第一次作，有一个指标没有注意，因此需要修改几个测试结果。那个没有注意的指标就是load average，他和我一样开始只是注意了CPU，内存的使用状况，而没有太注意这个指标，这个指标与他们通常的限制（10左右）有差别。重新测试的结果由于这个指标被要求压低，最后的报告显然不如原来的好看。自己也没有深入过压力测试，但是觉得不搞明白对将来机器配置和扩容都会有影响，因此去问了DBA和SA，得到的结果相差很大，看来不得不自己去找找问题的根本所在了。 通过下面的几个部分的了解，可以一步一步的找出Load Average在压力测试中真正的作用。 CPU时间片 为了提高程序执行效率，大家在很多应用中都采用了多线程模式，这样可以将原来的序列化执行变为并行执行，任务的分解以及并行执行能够极大地提高程序的运行效率。但这都是代码级别的表现，而硬件是如何支持的呢？那就要靠CPU的时间片模式来说明这一切。程序的任何指令的执行往往都会要竞争CPU这个最宝贵的资源，不论你的程序分成了多少个线程去执行不同的任务，他们都必须排队等待获取这个资源来计算和处理命令。先看看单CPU的情况。下面两图描述了时间片模式和非时间片模式下的线程执行的情况： 图 1 非时间片线程执行情况 图 2 非时间片线程执行情况 在图一中可以看到，任何线程如果都排队等待CPU资源的获取，那么所谓的多线程就没有任何实际意义。图二中的CPU Manager只是我虚拟的一个角色，由它来分配和管理CPU的使用状况，此时多线程将会在运行过程中都有机会得到CPU资源，也真正实现了在单CPU的情况下实现多线程并行处理。 多CPU的情况只是单CPU的扩展，当所有的CPU都满负荷运作的时候，就会对每一个CPU采用时间片的方式来提高效率。 在Linux的内核处理过程中，每一个进程默认会有一个固定的时间片来执行命令（默认为1/100秒），这段时间内进程被分配到CPU，然后独占使用。如果使用完，同时未到时间片的规定时间，那么就主动放弃CPU的占用，如果到时间片尚未完成工作，那么CPU的使用权也会被收回，进程将会被中断挂起等待下一个时间片。 CPU利用率和Load Average的区别 压力测试不仅需要对业务场景的并发用户等压力参数作模拟，同时也需要在压力测试过程中随时关注机器的性能情况，来确保压力测试的有效性。当服务器长期处于一种超负荷的情况下运行，所能接收的压力并不是我们所认为的可接受的压力。就好比项目经理在给一个人估工作量的时候，每天都让这个人工作12个小时，那么所制定的项目计划就不是一个合理的计划，那个人迟早会垮掉，而影响整体的项目进度。 CPU利用率在过去常常被我们这些外行认为是判断机器是否已经到了满负荷的一个标准，看到50%-60%的使用率就认为机器就已经压到了临界了。CPU利用率，顾名思义就是对于CPU的使用状况，这是对一个时间段内CPU使用状况的统计，通过这个指标可以看出在某一个时间段内CPU被占用的情况，如果被占用时间很高，那么就需要考虑CPU是否已经处于超负荷运作，长期超负荷运作对于机器本身来说是一种损害，因此必须将CPU的利用率控制在一定的比例下，以保证机器的正常运作。 Load Average是CPU的Load，它所包含的信息不是CPU的使用率状况，而是在一段时间内CPU正在处理以及等待CPU处理的进程数之和的统计信息，也就是CPU使用队列的长度的统计信息。为什么要统计这个信息，这个信息的对于压力测试的影响究竟是怎么样的，那就通过一个类比来解释CPU利用率和Load Average的区别以及对于压力测试的指导意义。 我们将CPU就类比为电话亭，每一个进程都是一个需要打电话的人。现在一共有4个电话亭（就好比我们的机器有4核），有10个人需要打电话。现在使用电话的规则是管理员会按照顺序给每一个人轮流分配1分钟的使用电话时间，如果使用者在1分钟内使用完毕，那么可以立刻将电话使用权返还给管理员，如果到了1分钟电话使用者还没有使用完毕，那么需要重新排队，等待再次分配使用。 图 3 电话使用场景 上图中对于使用电话的用户又作了一次分类，1min的代表这些使用者占用电话时间小于等于1min，2min表示使用者占用电话时间小于等于2min，以此类推。根据电话使用规则，1min的用户只需要得到一次分配即可完成通话，而其他两类用户需要排队两次到三次。 电话的利用率 = sum (active use cpu time)/period 每一个分配到电话的使用者使用电话时间的总和去除以统计的时间段。这里需要注意的是是使用电话的时间总和(sum(active use cpu time))，这与占用时间的总和(sum(occupy cpu time))是有区别的。（例如一个用户得到了一分钟的使用权，在10秒钟内打了电话，然后去查询号码本花了20秒钟，再用剩下的30秒打了另一个电话，那么占用了电话1分钟，实际只是使用了40秒） 电话的Average Load体现的是在某一统计时间段内，所有使用电话的人加上等待电话分配的人一个平均统计。 电话利用率的统计能够反映的是电话被使用的情况，当电话长期处于被使用而没有的到足够的时间休息间歇，那么对于电话硬件来说是一种超负荷的运作，需要调整使用频度。而电话Average Load却从另一个角度来展现对于电话使用状态的描述，Average Load越高说明对于电话资源的竞争越激烈，电话资源比较短缺。对于资源的申请和维护其实也是需要很大的成本，所以在这种高Average Load的情况下电话资源的长期“热竞争”也是对于硬件的一种损害。 低利用率的情况下是否会有高Load Average的情况产生呢？理解占有时间和使用时间就可以知道，当分配时间片以后，是否使用完全取决于使用者，因此完全可能出现低利用率高Load Average的情况。由此来看，仅仅从CPU的使用率来判断CPU是否处于一种超负荷的工作状态还是不够的，必须结合Load Average来全局的看CPU的使用情况和申请情况。 所以回过头来再看测试部对于Load Average的要求，在我们机器为8个CPU的情况下，控制在10 Load左右，也就是每一个CPU正在处理一个请求，同时还有2个在等待处理。看了看网上很多人的介绍一般来说Load简单的计算就是2* [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/12/18/919/load-average-good-understanding-of-stress-testing.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>touch &#8211;help</title>
		<link>http://blog.thematice.com/html/y2009/12/15/908/touch-help.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=touch-help</link>
		<comments>http://blog.thematice.com/html/y2009/12/15/908/touch-help.html#comments</comments>
		<pubDate>Tue, 15 Dec 2009 04:18:24 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[touch]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/html/y2009/12/15/908_touch-help.html</guid>
		<description><![CDATA[?Download shell.sh1 2 3 4 5 touch --help Usage: touch [OPTION]... FILE... Update the access and modification times of each FILE to the current time. &#160; Mandatory arguments to long options are mandatory for short options too. ?Download shell.sh1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -a change [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/12/15/908/touch-help.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux sort 命令详解</title>
		<link>http://blog.thematice.com/html/y2009/12/12/907/linux-sort-%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-sort-%25e5%2591%25bd%25e4%25bb%25a4%25e8%25af%25a6%25e8%25a7%25a3</link>
		<comments>http://blog.thematice.com/html/y2009/12/12/907/linux-sort-%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html#comments</comments>
		<pubDate>Fri, 11 Dec 2009 16:06:31 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/html/y2009/12/12/907_linux-sort-%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html</guid>
		<description><![CDATA[&#160; &#160;sort命令的功能是对文件中的各行进行排序。sort命令有许多非常实用的选项，这些选项最初是用来对数据库格式的文件内容进行各种排序操作的。实际上，sort命令可以被认为是一个非常强大的数据管理工具，用来管理内容类似数据库记录的文件。 　　Sort命令将逐行对文件中的内容进行排序，如果两行的首字符相同，该命令将继续比较这两行的下一字符，如果还相同，将继续进行比较。 　　语法： 　　sort ［选项］ 文件 　　说明：sort命令对指定文件中所有的行进行排序，并将结果显示在标准输出上。如不指定输入文件或使用”- “，则表示排序内容来自标准输入。 &#160;　　sort排序是根据从输入行抽取的一个或多个关键字进行比较来完成的。排序关键字定义了用来排序的最小的字符序列。缺省情况下以整行为关键字按ASCII字符顺序进行排序。 &#160;　　改变缺省设置的选项主要有： &#160;　　- m 若给定文件已排好序，合并文件。 &#160;　　- c 检查给定文件是否已排好序，如果它们没有都排好序，则打印一个出错信息，并以状态值1退出。 &#160;　　- u 对排序后认为相同的行只留其中一行。 &#160;　　- o 输出文件 将排序输出写到输出文件中而不是标准输出，如果输出文件是输入文件之一，sort先将该文件的内容写入一个临时文件，然后再排序和写输出结果。 &#160;　　改变缺省排序规则的选项主要有： &#160;　　- d 按字典顺序排序，比较时仅字母、数字、空格和制表符有意义。 &#160;　　- f 将小写字母与大写字母同等对待。 &#160;　　- I 忽略非打印字符。 &#160;　　- M 作为月份比较：”JAN”]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/12/12/907/linux-sort-%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINUX的du命令详解</title>
		<link>http://blog.thematice.com/html/y2009/11/01/786/linux%e7%9a%84du%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux%25e7%259a%2584du%25e5%2591%25bd%25e4%25bb%25a4%25e8%25af%25a6%25e8%25a7%25a3</link>
		<comments>http://blog.thematice.com/html/y2009/11/01/786/linux%e7%9a%84du%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html#comments</comments>
		<pubDate>Sun, 01 Nov 2009 08:44:08 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=786</guid>
		<description><![CDATA[命令用途 du(disk usage)命令可以计算文件或目录所占的磁盘空间。没有指定任何选项时，它会测量当前工作目录与其所有子目录，分别显示各个目录所占的快数，最后才显示工作目录所占总快数。 命令格式 ?Download shell1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 du [OPTION]... [FILE]... -a, --all 包括了所有的文件，而不只是目录 --apparent-size print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/11/01/786/linux%e7%9a%84du%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>输出man里面的内容乱码解决方案</title>
		<link>http://blog.thematice.com/html/y2009/10/19/763/garbled-output-of-man.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=garbled-output-of-man</link>
		<comments>http://blog.thematice.com/html/y2009/10/19/763/garbled-output-of-man.html#comments</comments>
		<pubDate>Mon, 19 Oct 2009 06:25:36 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[col]]></category>
		<category><![CDATA[man]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/html/y2009/10/19/763_%e8%be%93%e5%87%baman%e9%87%8c%e9%9d%a2%e7%9a%84%e5%86%85%e5%ae%b9%e4%b9%b1%e7%a0%81%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88.html</guid>
		<description><![CDATA[输出man里面的内容乱码解决方案 最近先把man 好好看看.我想用我的G1在公交车路上看.突然发现一个问题. 我直接man bash > man.txt后.拿过来的文件中间有乱码. 后来发现可以用col -b来过滤.执行后果然很好用..特意分享一下.. ?Download shell.sh1 man bash &#124; col -b &#62; man.txt ?Download max.txt1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/10/19/763/garbled-output-of-man.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>管理终端</title>
		<link>http://blog.thematice.com/html/y2009/10/19/762/management-terminal.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=management-terminal</link>
		<comments>http://blog.thematice.com/html/y2009/10/19/762/management-terminal.html#comments</comments>
		<pubDate>Mon, 19 Oct 2009 06:22:30 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/html/y2009/10/19/762_%e7%ae%a1%e7%90%86%e7%bb%88%e7%ab%af.html</guid>
		<description><![CDATA[通过bash shell终端显示的数据通常是通过ASCII编码的数据。用户也可以提交非ASCII编码的数据在终端中显示，终端程序会尽力执行。有时，终端会出现乱码，有时候会导致终端长时间的不响应。这时候，我们需要在终端中执行reset命令。执行reset命令的时候，我们可能看不到我们的输入字符。命令输入完成后，按回车键执行，终端就可以恢复正常操作。 Linux终端通过使用Ctrl键来发送特殊的信号。常用的组合键包括： 1、Ctrl+C——终止当前在bash中运行的进程，返回bash提示。 设备/dev/zero是一个伪设备，它的作用是在读取这个设备时，会返回无数个二进制零。 设备/dev/zero是一个伪设备，它的作用是将所有写入这个设备的信息全部丢弃。 2、Ctrl+D——向正在读取信息的进程发送信息传递完毕的信号。 wc命令在没有任何选项和参数的情况下，会对用户从键盘输入的行、词、和字符进行计数。 3、Ctrl+Z——用来挂起程序，挂起的程序可以使用fg命令来恢复。 fg命令是前台的缩写。 4、Ctrl+U——删除当前输入的行。 5、Ctrl+H——功能和Backspace（退格键）功能完全相同。 6、Ctrl+L——传统功能是停止打印当前页，并开始下一行。如果使用在线终端，可以用来刷新终端屏幕。在bash shell中，Ctrl+L组合键指示bash清屏，但是保持当前命令行。 所谓清屏只是将当前命令行显示到终端的第一行，并清除当前行的所有输入。之前执行的命令行都滚动到终端屏幕的上面。 7、Ctrl+S——将屏幕锁住。 8、Ctrl+Q——对锁住的屏幕进行解锁。 9、Ctrl+J——等同于“Enter”j建。 10、Ctrl+G——使终端发出一声振铃。 程序通过位于/dev目录的设备节点和终端在底层交流。大多数进程都会记录启动它们的终端，用户的登录会话通常与他们使用的终端相关。使用设备节点来辨识终端。 终端设备名称采用以下的方式标识： 1、 ttyn：虚拟控制台 2、 ttySn：串口终端设备 3、 pts/n：伪终端设备 4、 :0：X服务器 通过使用Tab键，可以实现命令和文件的补全功能。Tab键的补全功能不是终端的功能，而是bash shell的功能特征。 启动Unicode模式的命令是：unicode_start。停止Unicode模式的命令是：unicode_stop。 在使用Tab补全功能的时候，可能会出现以下两种情况：第一种情况是完整的将命令显示出来；第二种情况是显示一部分字符，然后系统提示一声振铃声。第一种情况下，Tab补全功能已经成功的完成了，第二种情况是系统存在多种选择，这时候你可以继续再按一下Tab键，终端会将可能的选项显示出来，供你选择。 Tab补全功能不仅可以帮助将命令补充完成，对于位于命令操作的文件也可以提供补全功能。和对命令的帮助是一样的，也可以通过按两次Tab键显示出可以选择的文件选项。 Linux系统帮助 在Linux下，为了获得系统的帮助，可以采用以下手段： 1、 通过在命令后面添加选项，我们可以获得命令使用方法的简短概要。常用的选项包括：-h、-?、—help。但是命令并不是支持所有的这些选项。有的命令不支持-?和-h选项。 2、 使用man page，可以获得大多数命令、文件格式、程序调用的文档。使用man命令浏览。man page分成8个标准章节。可以在man命令后面加上章节信息来说明你想浏览的是那一个章节。man命令中常用的两个参数是：（1）-k：用来进行关键词的搜索；（2）-a：可以用来浏览与指定参数相关的所有页的内容。 3、 使用Info page。只提供参考信息，而不提供一般的使用指导。记录了很多复杂命令的说明。在RedHat Linux系统下可以使用info和pinfo两个命令浏览info page。 4、 /usr/share/doc：包含一些未完善的文档。 5、 红帽文档指南。 6、 LDP——Linux文档项目，包括：FAQs、HOWTOs、GUIDEs。FAQs可以提供有关一个主题的常见问题；HOWTOs可以提供如何逐步设置或配置Linux的各个部分；GUIDEs可以更详细的介绍各个部分。 7、 yelp：GNOME帮助浏览器。可以在图形界面下使用的帮助工具。提供了许多GNOME图形应用程序的主要文档。 [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/10/19/762/management-terminal.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unix/Linux shell程序设计--case语句</title>
		<link>http://blog.thematice.com/html/y2009/09/26/736/unixlinux-shell%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1-case%e8%af%ad%e5%8f%a5.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=unixlinux-shell%25e7%25a8%258b%25e5%25ba%258f%25e8%25ae%25be%25e8%25ae%25a1-case%25e8%25af%25ad%25e5%258f%25a5</link>
		<comments>http://blog.thematice.com/html/y2009/09/26/736/unixlinux-shell%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1-case%e8%af%ad%e5%8f%a5.html#comments</comments>
		<pubDate>Sat, 26 Sep 2009 15:14:35 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[sed&swk&shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[sh]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=736</guid>
		<description><![CDATA[case语句 ：它能够把变量的内容与多个模板进行匹配,再根据成功匹配的模板去决定应该执行哪部分代码。 使用格式： case 匹配母板 in 模板1 [ &#124; 模板2 ] … ) 语句组 ;; 模板3 [ &#124; 模板4 ] … ) 语句组 ;; esac case语句的匹配是从上往下地匹配顺序。因此，case语句编写的原则是从上往下，模板从特殊到普通。在C语言里，case语句中有default模板，而在shell程序设计中，可能将模板写成*，就可以完成相同的功能。 case语句的模板支持匹配 匹配以n开头的所有情况： n* 匹配yes的所有字母大小不同的情况： [yY][eE][sS] 但不支持{}匹配，因为模板可以使用 &#124; 就可以达到目的。 例程: ?Download shell.sh1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #!/bin/sh &#160; [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/09/26/736/unixlinux-shell%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1-case%e8%af%ad%e5%8f%a5.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux下替换文件名中的空格用 tr :</title>
		<link>http://blog.thematice.com/html/y2009/09/24/732/linux%e4%b8%8b%e6%9b%bf%e6%8d%a2%e6%96%87%e4%bb%b6%e5%90%8d%e4%b8%ad%e7%9a%84%e7%a9%ba%e6%a0%bc%e7%94%a8-tr.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux%25e4%25b8%258b%25e6%259b%25bf%25e6%258d%25a2%25e6%2596%2587%25e4%25bb%25b6%25e5%2590%258d%25e4%25b8%25ad%25e7%259a%2584%25e7%25a9%25ba%25e6%25a0%25bc%25e7%2594%25a8-tr</link>
		<comments>http://blog.thematice.com/html/y2009/09/24/732/linux%e4%b8%8b%e6%9b%bf%e6%8d%a2%e6%96%87%e4%bb%b6%e5%90%8d%e4%b8%ad%e7%9a%84%e7%a9%ba%e6%a0%bc%e7%94%a8-tr.html#comments</comments>
		<pubDate>Thu, 24 Sep 2009 07:24:59 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux net]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[sh]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=732</guid>
		<description><![CDATA[Linux下替换文件名中的空格用 tr : ?Download shell.sh1 2 3 4 5 6 7 find . -type f -name &#34;* *&#34; -print &#124; while read name; do na=$(echo $name &#124; tr ' ' '_') if [[ $name != $na ]]; then mv &#34;$name&#34; $na fi done 记录在这里，希望对大家有用。]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/09/24/732/linux%e4%b8%8b%e6%9b%bf%e6%8d%a2%e6%96%87%e4%bb%b6%e5%90%8d%e4%b8%ad%e7%9a%84%e7%a9%ba%e6%a0%bc%e7%94%a8-tr.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rsync简单学习</title>
		<link>http://blog.thematice.com/html/y2009/09/23/719/rsync%e7%ae%80%e5%8d%95%e5%ad%a6%e4%b9%a0.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rsync%25e7%25ae%2580%25e5%258d%2595%25e5%25ad%25a6%25e4%25b9%25a0</link>
		<comments>http://blog.thematice.com/html/y2009/09/23/719/rsync%e7%ae%80%e5%8d%95%e5%ad%a6%e4%b9%a0.html#comments</comments>
		<pubDate>Wed, 23 Sep 2009 04:04:46 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux net]]></category>
		<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[net]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=719</guid>
		<description><![CDATA[rsync &#8211; faster, flexible replacement for rcp rsync是一个快速的，使用rcp协议来监视远程目录文件改动的同步工具，说实话，对于rsync的一些概念我至今都是模糊不清，它有太多的参数，还有超多的工作模式，以至于我实在是懒得去理会它。在我的心目中，它就是一个在服务器之间同步文件夹的工具。 下面，让我们来近距离接触它，我所知道的，Rhel和Sles在默认的情况就会安装rsync，想必其他系统也一样，所以我们不需要做任务动作，就可以直接使用它了。 另外我们可以发现有rsyncd服务端的存在，不过它是默认关闭的，我不知道它是用来做什么的，貌似要走873端口的一个协议，我不知道为什么放着ssh的22端口不用，又去另外开一个端口，开一个服务呢，所以我是坚决不用的，简单第一嘛。 现在我就要在服务器B上同步服务器A上的文件夹test，一旦服务器A上的test文件夹上有变动，服务器B上的test文件夹也有跟上，就是所谓的夫唱妇随，记住，A是夫，B是妇。 服务器A： ?Download shell.sh1 2 3 4 5 6 7 maxcv:~ # cd maxcv:~ # mkdir test maxcv:~ # cd test/ maxcv:~/test # touch a b c d e f g maxcv:~/test # chmod 777 * maxcv:~ # service sshd status Checking for service sshd [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/09/23/719/rsync%e7%ae%80%e5%8d%95%e5%ad%a6%e4%b9%a0.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux SHELL if 命令参数说明</title>
		<link>http://blog.thematice.com/html/y2009/09/21/673/linux-shell-if-%e5%91%bd%e4%bb%a4%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=linux-shell-if-%25e5%2591%25bd%25e4%25bb%25a4%25e5%258f%2582%25e6%2595%25b0%25e8%25af%25b4%25e6%2598%258e</link>
		<comments>http://blog.thematice.com/html/y2009/09/21/673/linux-shell-if-%e5%91%bd%e4%bb%a4%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e.html#comments</comments>
		<pubDate>Mon, 21 Sep 2009 08:32:53 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=673</guid>
		<description><![CDATA[放着备查 –b 当file存在并且是块文件时返回真 -c 当file存在并且是字符文件时返回真 -d 当pathname存在并且是一个目录时返回真 -e 当pathname指定的文件或目录存在时返回真 -f 当file存在并且是正规文件时返回真 -g 当由pathname指定的文件或目录存在并且设置了SGID位时返回为真 -h 当file存在并且是符号链接文件时返回真，该选项在一些老系统上无效 -k 当由pathname指定的文件或目录存在并且设置了“粘滞”位时返回真 -p 当file存在并且是命令管道时返回为真 -r 当由pathname指定的文件或目录存在并且可读时返回为真 -s 当file存在文件大小大于0时返回真 -u 当由pathname指定的文件或目录存在并且设置了SUID位时返回真 -w 当由pathname指定的文件或目录存在并且可执行时返回真。一个目录为了它的内容被访问必然是可执行的。 -o 当由pathname指定的文件或目录存在并且被子当前进程的有效用户ID所指定的用户拥有时返回真。 -x 是文件可执行时返回结果为真 UNIX Shell 里面比较字符写法： -eq 等于 -ne 不等于 -gt 大于 -lt 小于 -le 小于等于 -ge 大于等于 -z 空串 = 两个字符相等 != 两个字符不等 -n 非空串]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/09/21/673/linux-shell-if-%e5%91%bd%e4%bb%a4%e5%8f%82%e6%95%b0%e8%af%b4%e6%98%8e.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell中的数组使用方法</title>
		<link>http://blog.thematice.com/html/y2009/09/16/681/shell%e4%b8%ad%e7%9a%84%e6%95%b0%e7%bb%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=shell%25e4%25b8%25ad%25e7%259a%2584%25e6%2595%25b0%25e7%25bb%2584%25e4%25bd%25bf%25e7%2594%25a8%25e6%2596%25b9%25e6%25b3%2595</link>
		<comments>http://blog.thematice.com/html/y2009/09/16/681/shell%e4%b8%ad%e7%9a%84%e6%95%b0%e7%bb%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95.html#comments</comments>
		<pubDate>Wed, 16 Sep 2009 12:11:12 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=681</guid>
		<description><![CDATA[NAME rsync &#8211; faster, flexible replacement for rcp rsync是一个快速的，使用rcp协议来监视远程目录文件改动的同步工具，说实话，对于rsync的一些概念我至今都是模糊不清，它有太多的参数，还有超多的工作模式，以至于我实在是懒得去理会它。在我的心目中，它就是一个在服务器之间同步文件夹的工具。 下面，让我们来近距离接触它，我所知道的，Rhel和Sles在默认的情况就会安装rsync，想必其他系统也一样，所以我们不需要做任务动作，就可以直接使用它了。 另外我们可以发现有rsyncd服务端的存在，不过它是默认关闭的，我不知道它是用来做什么的，貌似要走873端口的一个协议，我不知道为什么放着ssh的22端口不用，又去另外开一个端口，开一个服务呢，所以我是坚决不用的，简单第一嘛。 现在我就要在服务器B上同步服务器A上的文件夹test，一旦服务器A上的test文件夹上有变动，服务器B上的test文件夹也有跟上，就是所谓的夫唱妇随，记住，A是夫，B是妇。 服务器A： ?Download shell.sh1 2 3 4 5 6 7 8 9 &#60;ol class=&#34;dp-c&#34;&#62; &#60;li class=&#34;alt&#34;&#62;&#60;span&#62;&#60;span&#62;maxcv:~ # &#60;span style=&#34;color: #993300;&#34;&#62;cd &#60;/span&#62;&#60;/span&#62;&#60;/span&#62;&#60;/li&#62; &#60;li&#62;&#60;span&#62;maxcv:~ # &#60;span style=&#34;color: #993300;&#34;&#62;mkdir test &#60;/span&#62;&#60;/span&#62;&#60;/li&#62; &#60;li class=&#34;alt&#34;&#62;&#60;span&#62;maxcv:~ # &#60;span style=&#34;color: #993300;&#34;&#62;cd test/ &#60;/span&#62;&#60;/span&#62;&#60;/li&#62; &#60;li&#62;&#60;span&#62;maxcv:~/test # &#60;span style=&#34;color: #993300;&#34;&#62;touch a b c [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/09/16/681/shell%e4%b8%ad%e7%9a%84%e6%95%b0%e7%bb%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python常用的时间方法</title>
		<link>http://blog.thematice.com/html/y2009/05/18/431/python-commonly-used-methods-of-time.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-commonly-used-methods-of-time</link>
		<comments>http://blog.thematice.com/html/y2009/05/18/431/python-commonly-used-methods-of-time.html#comments</comments>
		<pubDate>Mon, 18 May 2009 15:24:15 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=431</guid>
		<description><![CDATA[我们先导入必须用到的一个module >>> import time 设置一个时间的格式，下面会用到 >>>ISOTIMEFORMAT=’%Y-%m-%d %X’ 看一下当前的时间，和其他很多语言相似这是从epoch（1970 年 1 月 1 日 00:00:00）开始到当前的秒数。 >>> time.time() 1180759620.859 上面的看不懂，换个格式来看看 >>> time.localtime() (2007, 6, 2, 12, 47, 7, 5, 153, 0) localtime返回tuple格式的时间，有一个和它类似的函数叫gmtime(),2个函数的差别是时区，gmtime()返回的是0时区的值，localtime返回的是当前时区的值。 >>> time.strftime( ISOTIMEFORMAT, time.localtime() ) ‘2007-06-02 12:54:29′ 用上我们的时间格式定义了，使用strftime对时间做一个转换，如果取现在的时间，time.localtime() 可以不用。 >>> time.strftime( ISOTIMEFORMAT, time.localtime( time.time() ) ) ‘2007-06-02 12:54:31′ >>> time.strftime( ISOTIMEFORMAT, time.gmtime( time.time() ) ) [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/05/18/431/python-commonly-used-methods-of-time.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bg和fg</title>
		<link>http://blog.thematice.com/html/y2009/05/18/429/bg%e5%92%8cfg.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bg%25e5%2592%258cfg</link>
		<comments>http://blog.thematice.com/html/y2009/05/18/429/bg%e5%92%8cfg.html#comments</comments>
		<pubDate>Mon, 18 May 2009 09:43:20 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[ctrel+z]]></category>
		<category><![CDATA[fg]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[后台]]></category>
		<category><![CDATA[执行]]></category>
		<category><![CDATA[脚本]]></category>

		<guid isPermaLink="false">http://blog.thematice.com/?p=429</guid>
		<description><![CDATA[Linux/Unix 区别于微软平台最大的优点就是真正的多用户，多任务。因此在任务管理上也有别具特色的管理思想。 我们知道，在 Windows 上面，我们要么让一个程序作为服务在后台一直运行，要么停止这个服务。而不能让程序在前台后台之间切换。而 Linux 提供了 fg 和 bg 命令，让你轻松调度正在运行的任务。 假设你发现前台运行的一个程序需要很长的时间，但是需要干其他的事情，你就可以用 Ctrl-Z ，挂起这个程序，然后可以看到系统提示： [1]+ Stopped /root/bin/rsync.sh 然后我们可以把程序调度到后台执行：（bg 后面的数字为作业号） #bg 1 [1]+ /root/bin/rsync.sh &#038; 用 jobs 命令查看正在运行的任务： #jobs [1]+ Running /root/bin/rsync.sh &#038; 如果想把它调回到前台运行，可以用 #fg 1 /root/bin/rsync.sh 这样，你在控制台上就只能等待这个任务完成了。]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2009/05/18/429/bg%e5%92%8cfg.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>深入浅出Shell编程: Shell 变量</title>
		<link>http://blog.thematice.com/html/y2008/03/10/71/shell-programming-in-simple-terms-shell-variables.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=shell-programming-in-simple-terms-shell-variables</link>
		<comments>http://blog.thematice.com/html/y2008/03/10/71/shell-programming-in-simple-terms-shell-variables.html#comments</comments>
		<pubDate>Mon, 10 Mar 2008 09:58:53 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.gruelstate.cn/?p=71</guid>
		<description><![CDATA[先不要管Shell的版本，来看看Shell 变量，在Shell中有三种变量：系统变量，环境变量，用户变量。其中用户变量在编程过程中使用最多，系统变量在对参数判断和命令返回值判断会使用，环境变量主要是在程序运行的时候需要设置。 1 系统变量 Shell常用的系统变量并不多，但却十分有用，特别是在做一些参数检测的时候。下面是Shell常用的系统变量 表示方法 描述 $n $1 表示第一个参数，$2 表示第二个参数 &#8230; $# 命令行参数的个数 $0 当前程序的名称 $? 前一个命令或函数的返回码 $* 以”参数1 参数2 &#8230; ” 形式保存所有参数 $@ 以”参数1&#8243; “参数2&#8243; &#8230; 形式保存所有参数 $$ 本程序的(进程ID号)PID $! 上一个命令的PID 其中使用得比较多得是 $n $# $0 $? ,看看下面的例子： BeautifierPlugin Error: Unable to handle “bash” syntax. #!/bin/sh #This file is used to explain the shell [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2008/03/10/71/shell-programming-in-simple-terms-shell-variables.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>seq的用法</title>
		<link>http://blog.thematice.com/html/y2008/03/10/70/use-seq.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=use-seq</link>
		<comments>http://blog.thematice.com/html/y2008/03/10/70/use-seq.html#comments</comments>
		<pubDate>Mon, 10 Mar 2008 09:56:48 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[linux shell]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[seq]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.gruelstate.cn/?p=70</guid>
		<description><![CDATA[seq用于产生从某个数到另外一个数之间的所有整数 例一： # seq 1 10 结果是1 2 3 4 5 6 7 8 9 10 例二： #!/bin/bash for i in `seq 1 10`; do echo $i; done 或者用 for i in $(seq 1 10)]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2008/03/10/70/use-seq.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crontab 笔记</title>
		<link>http://blog.thematice.com/html/y2007/12/20/43/crontab-%e7%ac%94%e8%ae%b0.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=crontab-%25e7%25ac%2594%25e8%25ae%25b0</link>
		<comments>http://blog.thematice.com/html/y2007/12/20/43/crontab-%e7%ac%94%e8%ae%b0.html#comments</comments>
		<pubDate>Thu, 20 Dec 2007 07:34:33 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Linux tools]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.gruelstate.cn/index.php/2007/12/20/crontab-%e7%ac%94%e8%ae%b0/</guid>
		<description><![CDATA[关于 Crontab ，维基百科上的词条 Crontab非常好。可惜这个地址在国内不用代理访问不到。 虽然关于 Crontab 的介绍到处都是，详细读了一遍这个词条，收获还是有的。Crontab 这个名字来自 “chronos”，一个古希腊语, “时间”的意思. 常见陷阱 每个SA、DBA 或者是普通的 Unix 用户，在第一次使用 Crontab 的时候都会遇到问题. 运行 Crontab 的常见错误包括如下几种:1) 出于测试目的新创建了一条 Cron JOB, 时间间隔必须超过两分钟，否则 JOB 将调度不到。如果必须忽略这两分钟的载入配置时间差，可以通过重新启动 Cron Daemon 做到。 2) 从 Crontab 中启动 X Window 程序需要注意的事项：所以要么在程序前初始化 “DISPLAY=:0.0&#8243;, 要么在应用程序后面追加参数 &#8211;display :0.0 3) 命令中的 % 必须做转义处理: \% .我个人的意见是不要在命令行里带这个参数，干脆写到脚本里，然后调度该脚本即可。 其实我倒是认为使用 Crontab 最常见的一个问题往往是因为环境变量不对。经常会看到论坛里有人问：为什么我的 Crontab 创建了不执行? 准备创建一条 Cron JOB 的时候，很多人都喜欢在命令行下运行一遍，因为这个时候环境变量是随着 [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2007/12/20/43/crontab-%e7%ac%94%e8%ae%b0.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何用php作Linux自动执行脚本？</title>
		<link>http://blog.thematice.com/html/y2007/11/24/33/%e5%a6%82%e4%bd%95%e7%94%a8php%e4%bd%9clinux%e8%87%aa%e5%8a%a8%e6%89%a7%e8%a1%8c%e8%84%9a%e6%9c%ac%ef%bc%9f.html#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%25a6%2582%25e4%25bd%2595%25e7%2594%25a8php%25e4%25bd%259clinux%25e8%2587%25aa%25e5%258a%25a8%25e6%2589%25a7%25e8%25a1%258c%25e8%2584%259a%25e6%259c%25ac%25ef%25bc%259f</link>
		<comments>http://blog.thematice.com/html/y2007/11/24/33/%e5%a6%82%e4%bd%95%e7%94%a8php%e4%bd%9clinux%e8%87%aa%e5%8a%a8%e6%89%a7%e8%a1%8c%e8%84%9a%e6%9c%ac%ef%bc%9f.html#comments</comments>
		<pubDate>Sat, 24 Nov 2007 01:39:14 +0000</pubDate>
		<dc:creator>稀饭</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.gruelstate.cn/index.php/2007/11/24/%e5%a6%82%e4%bd%95%e7%94%a8php%e4%bd%9clinux%e8%87%aa%e5%8a%a8%e6%89%a7%e8%a1%8c%e8%84%9a%e6%9c%ac%ef%bc%9f/</guid>
		<description><![CDATA[最近急需这种方法，记录一下，明天上班时候尝试^^ 在  linux下，可以使用crontab  +  php的方法： 1、使用crontab  –e编辑定时任务 内容为: xx:xx:xx  执行一个test.php文件 2、php文件必须在文件头一行，加上解释器路径（就象perl做的那样） #!/usr/local/bin/php PHP的执行需要Apache的支持，shell脚本的执行需要Linux的支持，而Linux支持定时运行某个程序的功能 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 将PHP作为Shell脚本语言使用(转载) －－英文原著：Darrell  Brogdon，发表于  http://www.phpbuilder.com/columns/darrell20000319.php3） 可能很多人都想过使用PHP编写一些定时发信之类的程序，但是却没有办法定时执行PHP；一次去PHPBuilder的时候，发现了这一篇文章，于是想给大家翻译一下（同时做了一些修改），希望对大家有用。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 我 们都知道，PHP是一种非常好的动态网页开发语言（速度飞快，开发周期短……）。但是只有很少数的人意识到PHP也可以很好的作为编写Shell脚本的语 言，当PHP作为编写Shell脚本的语言时，他并没有Perl或者Bash那么强大，但是他却有着很好的优势，特别是对于我这种熟悉PHP但是不怎么熟 悉Perl的人。 要使用PHP作为Shell脚本语言，你必须将PHP作为二进制的CGI编译，而不是Apache模式；编译成为二进制CGI模式运行的PHP有一些安全性的问题，关于解决的方法可以参见PHP手册（http://www.php.net）。 一开始你可能会对于编写Shell脚本感到不适应，但是会慢慢好起来的：将PHP作为一般的动态网页编写语言和作为Shell脚本语言的唯一不同就在于一个Shell脚本需要在第一行生命解释本脚本的程序路径： #!/usr/local/bin/php  -q 我们在PHP执行文件后面加入了参数“-1”，这样子PHP就不会输出HTTPHeader（如果仍需要作为Web的动态网页，那么你需要自己使用header函数输出HTTPHeader）。当然，在Shell脚本的里面你还是需要使用PHP的开始和结束标记： &#60;?php  代码  ?&#62; 现在让我们看一个例子，以便于更好的了解用PHP作为Shell脚本语言的使用： #!/usr/local/bin/php  -q &#60;?php print(“Hello,  world!\n”); ?&#62; 上面这个程序会简单的输出“Hello,  world!”到显示器上。 一、传递Shell脚本运行参数给PHP： 作 为一个Shell脚本，经常会在运行程序时候加入一些参数，PHP作为Shell脚本时有一个内嵌的数组“$argv”，使用“$argv”数组可以很方 便的读取Shell脚本运行时候的参数（“$argv[1]”对应的是第一个参数，“$argv[2]”对应的是第二个参数，依此类推）。比如下面这个程 序： #!/usr/local/bin/php  -q &#60;?php $first_name  =  $argv[1]; $last_name  =  $argv[2]; [...]]]></description>
		<wfw:commentRss>http://blog.thematice.com/html/y2007/11/24/33/%e5%a6%82%e4%bd%95%e7%94%a8php%e4%bd%9clinux%e8%87%aa%e5%8a%a8%e6%89%a7%e8%a1%8c%e8%84%9a%e6%9c%ac%ef%bc%9f.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

