<?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>IPCPU——网络之路 &#187; Shell</title>
	<atom:link href="http://www.ipcpu.com/tag/shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ipcpu.com</link>
	<description></description>
	<lastBuildDate>Sat, 03 Dec 2011 17:16:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>&gt;/dev/null 2&gt;&amp;1和&amp;&gt;/dev/null.的区别问题</title>
		<link>http://www.ipcpu.com/2010/10/dev-null-2-1/</link>
		<comments>http://www.ipcpu.com/2010/10/dev-null-2-1/#comments</comments>
		<pubDate>Sat, 23 Oct 2010 15:10:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[kash]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ipcpu.com/?p=797</guid>
		<description><![CDATA[bash环境作了如下实验： [root@s253.ipcpu.com ~]# balabala -bash: balabala: command not found [root@s253.ipcpu.com ~]# balabala &#38;&#62; /dev/null [root@s253.ipcpu.com ~]# balabala &#62;/dev/null 2&#62;&#38;1 [root@s253.ipcpu.com ~]# balabala &#62; /dev/null 2&#62;&#38;1 [root@s253.ipcpu.com ~]# 两条命令等价。 网友给出ksh和bash对比 /home/lee#echo $0 -ksh /home/lee#ls abc &#62;/dev/null 2&#62;&#38;1 /home/lee#ls abc &#38;&#62;/dev/null ls: abc: 没有那个文件或目录 [1] 1524 [1] + Done (1)             ls &#8211;color=tty abc /home/lee#bash /home/lee#echo $0 bash [...]]]></description>
			<content:encoded><![CDATA[<p>bash环境作了如下实验：</p>
<p>[root@s253.ipcpu.com ~]# balabala<br />
-bash: balabala: command not found<br />
[root@s253.ipcpu.com ~]# balabala &amp;&gt; /dev/null<br />
[root@s253.ipcpu.com ~]# balabala &gt;/dev/null 2&gt;&amp;1<br />
[root@s253.ipcpu.com ~]# balabala &gt; /dev/null 2&gt;&amp;1<br />
[root@s253.ipcpu.com ~]#</p>
<p>两条命令等价。</p>
<p>网友给出ksh和bash对比<br />
/home/lee#echo $0<br />
-ksh<br />
/home/lee#ls abc &gt;/dev/null 2&gt;&amp;1<br />
<span style="color: #ff0000;">/home/lee#ls abc &amp;&gt;/dev/null</span><br />
ls: abc: 没有那个文件或目录<br />
[1] 1524<br />
[1] + Done (1)             ls &#8211;color=tty abc<br />
/home/lee#bash<br />
/home/lee#echo $0<br />
bash<br />
/home/lee#ls abc &gt;/dev/null 2&gt;&amp;1<br />
<span style="color: #ff0000;">/home/lee#ls abc &amp;&gt;/dev/null</span><br />
显然在ksh就不一样了，<strong>所以推荐使用&gt;/dev/null 2&gt;&amp;1</strong></p>
<p>参考资料：<br />
<a href="http://bbs.chinaunix.net/viewthread.php?tid=610827">http://bbs.chinaunix.net/viewthread.php?tid=610827</a></p>
<p>后记：</p>
<p>2&gt;&amp;1 和 &amp;&gt;  的解释</p>
<p>Linux的IO输入输出有三类</p>
<p>Standard Input      代码 0<br />
Standard Output  代码  1<br />
Standard Error     代码 2</p>
<p>ls thereisno 1&gt; out.txt  标准输出重定向  也可以不加1写成 ls thereisno &gt; out.txt</p>
<p> ls thereisno 2&gt; out.txt  标准错误重定向</p>
<p> ls thereisno &gt; out.txt  2&gt;&amp;1  把错误定向到标准输出，然后统一重定向</p>
<p> ls thereisno &amp;&gt; out.txt  所有IO重定向(&amp;&gt;中的&amp;可以代表任意，0，1，2，3……)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipcpu.com/2010/10/dev-null-2-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux学习笔记之locate命令</title>
		<link>http://www.ipcpu.com/2010/08/linux-study-locate/</link>
		<comments>http://www.ipcpu.com/2010/08/linux-study-locate/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 13:36:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[命令]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ipcpu.com/?p=739</guid>
		<description><![CDATA[语法： [root @test /root ]# locate [目录名称] 范例： [root @test /root]# locate root     ……一大堆跟root 有关字眼的档案都出来了@_@ [root @test /root]# updatedb &#60;==立刻更新资料库    说明： locate 的使用方式就更简单了！直接键入你要找的档名即可！但是，这个东西还是有使用上的限制呦！为什么呢？您会发现使用locate 来寻找资料的时候特别的快，这是因为locate 寻找的资料是由『已建立的资料库/var/lib/slocate』里面的资料所搜寻到的，所以不用直接在去硬碟当中存取资料，呵呵！当然是很快速啰！那么有什么限制呢？就是因为他是经由资料库来搜寻的，而资料库的建立预设是在每个礼拜执行一次，所以当您新建立起来的档案，却还在资料库更新之前搜寻该档案，那么locate 会告诉您『找不到！ 』呵呵！因为必须要更新资料库呀！     　       那么我到底要建立哪些资料库呢？是否全部都要建立？似乎不需要，这个时候，你可以自己选择需要建立档案资料库的目录呢！在/etc/updatedb.conf 这个内即可设定了！ [root @test root]# more /etc/updatedb.conf ## Linux-Mandrake configuration. # 由何处开始查询资料，当然是由根目录啦！所以填入 / 即可 FROM=&#8221;/&#8221; # 哪些目录不想要建立档案搜寻资料，呵呵！就是那些不要的资料嘛！ # 忘记的话，记得回上一章去看看内容，就知道为何如此设定了！ PRUNEPATHS=&#8221;/proc,/tmp,/var/tmp,/usr/tmp,/net,/afs,/mnt&#8221;      # 安全等级 [...]]]></description>
			<content:encoded><![CDATA[<p>语法：<br />
[root @test /root ]# locate [目录名称]</p>
<p>范例：<br />
[root @test /root]# locate root<br />
    ……一大堆跟root 有关字眼的档案都出来了@_@<br />
[root @test /root]# updatedb &lt;==立刻更新资料库<br />
  <br />
说明：<br />
locate 的使用方式就更简单了！直接键入你要找的档名即可！但是，这个东西还是有使用上的限制呦！为什么呢？您会发现使用locate 来寻找资料的时候特别的快，这是因为locate 寻找的资料是由『已建立的资料库/var/lib/slocate』里面的资料所搜寻到的，所以不用直接在去硬碟当中存取资料，呵呵！当然是很快速啰！那么有什么限制呢？就是因为他是经由资料库来搜寻的，而资料库的建立预设是在每个礼拜执行一次，所以当您新建立起来的档案，却还在资料库更新之前搜寻该档案，那么locate 会告诉您『找不到！ 』呵呵！因为必须要更新资料库呀！<br />
    　<br />
      那么我到底要建立哪些资料库呢？是否全部都要建立？似乎不需要，这个时候，你可以自己选择需要建立档案资料库的目录呢！在/etc/updatedb.conf 这个内即可设定了！<br />
[root @test root]# more /etc/updatedb.conf<br />
## Linux-Mandrake configuration.<br />
# 由何处开始查询资料，当然是由根目录啦！所以填入 / 即可<br />
FROM=&#8221;/&#8221;<br />
# 哪些目录不想要建立档案搜寻资料，呵呵！就是那些不要的资料嘛！<br />
# 忘记的话，记得回上一章去看看内容，就知道为何如此设定了！<br />
PRUNEPATHS=&#8221;/proc,/tmp,/var/tmp,/usr/tmp,/net,/afs,/mnt&#8221; <span id="more-739"></span><br />
    <br />
# 安全等级<br />
# 0 代表关闭安全检验，速度上面较快速，但较不安全；<br />
# 1 启动安全简易，这是系统的预设值；<br />
SECURITY=&#8221;1&#8243;<br />
    <br />
# 查询的时候是否要由萤幕输出？当然不要，否则多麻烦?<br />
VERBOSE=&#8221;NO&#8221;<br />
    <br />
# 资料库所在处！这是预设值，不要随意移动，否则会找不到！<br />
DATABASE=&#8221;/var/lib/slocate/slocate.db&#8221;<br />
    <br />
# 哪些档案系统我们也不搜寻建立？就是光碟啦、非Linux 的档案格式啦，<br />
# 我们都不要进行搜寻资讯的建立啦！<br />
    PRUNEFS=&#8221;nfs,smbfs,ncpfs,proc,devpts,supermount,vfat,iso9660,udf,usbdevfs,devfs&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipcpu.com/2010/08/linux-study-locate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>关于find中的atime、ctime、mtime的区别</title>
		<link>http://www.ipcpu.com/2010/07/linux-find-atime-ctime/</link>
		<comments>http://www.ipcpu.com/2010/07/linux-find-atime-ctime/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 11:04:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[命令]]></category>

		<guid isPermaLink="false">http://www.ipcpu.com/?p=673</guid>
		<description><![CDATA[这几天碰到的一个面试题。 find用法：     -atime n               File was last accessed n*24 hours ago.  访问（读取文件或执行文件）         -ctime n               File’s status was last changed n*24 hours ago.  写入修改 更改属主  -mtime n               File’s  data was last modified n*24 hours ago.  写入修改    -amin n               File was last accessed n minutes ago.这是按分钟来算的一般不用  -cmin n               File’s [...]]]></description>
			<content:encoded><![CDATA[<p>这几天碰到的一个面试题。</p>
<p>find用法：<br />
 <br />
  -atime n<br />
              File was last accessed n*24 hours ago.  访问（读取文件或执行文件）<br />
      <br />
 -ctime n<br />
              File’s status was last changed n*24 hours ago.  写入修改 更改属主</p>
<p> -mtime n<br />
              File’s  data was last modified n*24 hours ago.  写入修改<br />
 <br />
 -amin n<br />
              File was last accessed n minutes ago.这是按分钟来算的一般不用<br />
 -cmin n<br />
              File’s status was last changed n minutes ago.</p>
<p>关于+n还是-n</p>
<p>        +n     for greater than n,  #N天以外的，N天前的</p>
<p>        -n     for less than n,     #N天以内的</p>
<p>        n      for exactly n.     #正好的</p>
<p>例子：<br />
-bash-3.2$ ll<br />
total 24<br />
-rw-r&#8211;r&#8211; 1 wss8848 member    6 2010-07-13 20:58 1.txt<br />
-rw-r&#8211;r&#8211; 1 wss8848 member   63 2010-07-11 21:08 awk.txt<br />
-rwxr&#8211;r&#8211; 1 wss8848 member  160 2010-<span style="color: #ff0000;">07-04</span> 00:00 if.sh<br />
-bash-3.2$ <span style="color: #ff0000;">find -atime +8</span><br />
<span style="color: #ff0000;">./if.sh</span><br />
-bash-3.2$ date<br />
Tue <span style="color: #ff0000;">Jul 13</span> 21:31:04 CST 2010<br />
-bash-3.2$</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipcpu.com/2010/07/linux-find-atime-ctime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux学习笔记之find命令</title>
		<link>http://www.ipcpu.com/2010/06/linux-find-command/</link>
		<comments>http://www.ipcpu.com/2010/06/linux-find-command/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 15:17:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ipcpu.com/?p=655</guid>
		<description><![CDATA[1.如果想在当前目录查找文件名以两个小写字母开头，跟着是两个数字，最后是*.txt的文件，下面的命令就能够返回名为ax37.txt的文件：   $ find . -name  &#8220;[a-z][a-z][0--9][0--9].txt&#8221; -print 2.想要在当前目录及子目录中查找所有的‘*.txt’文件，可以用：   $ find . -name  &#8220;*.txt&#8221; -print 3.想要查找txt后缀，并且权限644的文件   $ find ~ -name &#8220;*.txt&#8221; -perm 644 -print 4.在$HOME目录中查找文件属主为dave的文件，可以用：   $ find ~ -user  dave -print 5.希望在系统根目录下查找更改时间在5日以内的文件，可以用：   $ find/-mtime -5 -print   6.为了在/var/adm目录下查找更改时间在3日以前的文件，可以用：   $ find /var/adm  -mtime +3 -print   【4、5是碰到的面试题，可惜那时不懂】 7.如果要在/etc目录下查找所有的目录，可以用：   $find /etc -type  [...]]]></description>
			<content:encoded><![CDATA[<p>1.如果想在当前目录查找文件名以两个小写字母开头，跟着是两个数字，最后是*.txt的文件，下面的命令就能够返回名为ax37.txt的文件：<br />
  $ find . -name  &#8220;[a-z][a-z][0--9][0--9].txt&#8221; -print</p>
<p>2.想要在当前目录及子目录中查找所有的‘*.txt’文件，可以用：<br />
  $ find . -name  &#8220;*.txt&#8221; -print</p>
<p>3.想要查找txt后缀，并且权限644的文件<br />
  $ find ~ -name &#8220;*.txt&#8221; -perm 644 -print</p>
<p>4.在$HOME目录中查找文件属主为dave的文件，可以用：<br />
  $ find ~ -user  dave -print</p>
<p>5.希望在系统根目录下查找更改时间在5日以内的文件，可以用：<br />
  $ find/-mtime -5 -print<br />
 <br />
6.为了在/var/adm目录下查找更改时间在3日以前的文件，可以用：<br />
  $ find /var/adm  -mtime +3 -print   【4、5是碰到的面试题，可惜那时不懂】</p>
<p>7.如果要在/etc目录下查找所有的目录，可以用：<br />
  $find /etc -type  d -print<br />
 <br />
8.为了在当前目录下查找除目录以外的所有类型的文件，可以用：<br />
  $find . ! -type  d -print</p>
<p>9.为了在当前目录下查找文件长度大于1M字节的文件，可以用：<br />
  $find . -size  +1000000c -print<br />
 <br />
10.为了在/home/apache目录下查找文件长度恰好为100字节的文件，可以用：<br />
  $find /home /apache  -size 100c -print</p>
<p>11. 下面的例子在/apps/audit目录下查找所有用户具有读、写和执行权限的文件，并收回相应的写权限：<br />
  $ find /apps/audit  -perm -7 -print | xargs chmod o -w</p>
<p>find命令是一个非常优秀的工具，它可以按照用户指定的准则来匹配文件。使用exec和xargs可以使用户对所匹配到的文件执行几乎所有的命令。</p>
<p>=======================<br />
修改文件时间戳<br />
touch -t 201007042254 we.txt<br />
touch -d 20100704 you.txt</p>
<p>======================</p>
<p>find 学习笔记 enhenced 2</p>
<p>查找文件并对查找的文件执行命令</p>
<p><span style="color: #ff0000;"><strong>Command must end with Space\;命令必须以空格加\;结束</strong></span></p>
<p>find -name &#8220;*.conf&#8221; -exec cp {} {}.orig \;</p>
<p>查找.conf结尾的文件，并以文件名.orgi进行备份</p>
<p>find /tmp -ctime +3 -user joe -ok rm {} \;</p>
<p>删除tmp中用户joe三天前的文件</p>
<p>find ~ -perm +o+w -exec chmod o-w {} \;</p>
<p>去掉可写文件写权限</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipcpu.com/2010/06/linux-find-command/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux学习笔记Shell常用命令补充(一)</title>
		<link>http://www.ipcpu.com/2010/04/linux-shell-attached/</link>
		<comments>http://www.ipcpu.com/2010/04/linux-shell-attached/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 08:59:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.ipcpu.com/?p=454</guid>
		<description><![CDATA[gzip test.txt压缩后源文件删除！ bzip2 3.txt也是如此 在与tar联合使用时z代表gzip压缩，j代表bzip2压缩。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; [wss8848@wss ~]$ mkdir wss mkdir: 无法创建目录 “wss”: 文件已存在 ！！统一文件夹下不能存在重名文件和文件夹。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- 时间设置 (1)date 042612492005 (2)hwclock -w &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; which和whereis [wss8848@wss bin]$ which ll alias ll=&#8217;ls -l &#8211;color=auto&#8217; /bin/ls [wss8848@wss ~]$ which ls alias ls=&#8217;ls &#8211;color=auto&#8217; /bin/ls [wss8848@wss ~]$ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz !!whereis显示程序位置及相关文档工具等。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- [root@wss wss8848]# free -m 以兆为单位-g以吉为单位 [...]]]></description>
			<content:encoded><![CDATA[<p>gzip test.txt压缩后源文件删除！<br />
bzip2 3.txt也是如此<br />
在与tar联合使用时z代表gzip压缩，j代表bzip2压缩。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[wss8848@wss ~]$ mkdir wss<br />
mkdir: 无法创建目录 “wss”: 文件已存在<br />
！！统一文件夹下不能存在重名文件和文件夹。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
时间设置<br />
(1)date 042612492005<br />
(2)hwclock -w<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
which和whereis<br />
[wss8848@wss bin]$ which ll<br />
alias ll=&#8217;ls -l &#8211;color=auto&#8217;<br />
/bin/ls<br />
[wss8848@wss ~]$ which ls<br />
alias ls=&#8217;ls &#8211;color=auto&#8217;<br />
/bin/ls<br />
[wss8848@wss ~]$ whereis ls<br />
ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz<br />
!!whereis显示程序位置及相关文档工具等。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[root@wss wss8848]# free -m 以兆为单位-g以吉为单位<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
帮助命令<br />
man ls或者<br />
ls &#8211;help<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
运行可执行文件<br />
# ./filename<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
GNOME文件管理起Nautilus<br />
只用一个窗口显示 按住Shift或者使用鼠标中键。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
安装XFCE桌面<br />
&#8216;yum groupinstall xfce<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[root@wss ~]# yum install swfdec-mozilla<br />
安装flash插件。<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>linux运行级别：0关机  6重启（别反了）</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>rlogin远程登录！不是telnet和ssh</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ipcpu.com/2010/04/linux-shell-attached/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

