<?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>vifix.cn &#187; CLI</title>
	<atom:link href="http://vifix.cn/blog/tag/cli/feed" rel="self" type="application/rss+xml" />
	<link>http://vifix.cn/blog</link>
	<description>compile the dream, compile tomorrow</description>
	<lastBuildDate>Sat, 04 Feb 2012 03:15:56 +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>convmv &#8211; Linux下修改文件名编码</title>
		<link>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html</link>
		<comments>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html#comments</comments>
		<pubDate>Wed, 19 Oct 2011 09:01:28 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2173</guid>
		<description><![CDATA[今天在公司tar打包一些编码为GBK的中文文件名的文件时打包碰到的问题。我自己的locale是en_US.UTF8，那台主机的环境是zh_CN.GBK，因此tar不管怎么打包，都会使文件名出现问题。而如果采用7z打包，虽然可以解决乱码问题（7z会记录下文件名的编码），但会丢失文件属性，所以不打算采用。 google了下发现可以通过convmv来进行解决： convmv -f GBK -t UTF8 -r --notest target 其中-f是源编码，-t是目标编码，-r是递归处理目录，&#8211;notest是不移动，实际上对文件进行改名（actually do rename the files），target是目标目录。其余参数可以参考man或者-h。 另外一个方案是google到了一个python脚本，通过python的tarfile包解决问题，感兴趣的可以看看这个link: http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem]]></description>
			<content:encoded><![CDATA[<p>今天在公司tar打包一些编码为GBK的中文文件名的文件时打包碰到的问题。我自己的locale是en_US.UTF8，那台主机的环境是zh_CN.GBK，因此tar不管怎么打包，都会使文件名出现问题。而如果采用7z打包，虽然可以解决乱码问题（7z会记录下文件名的编码），但会丢失文件属性，所以不打算采用。</p>
<p>google了下发现可以通过convmv来进行解决：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">convmv <span style="color: #660033;">-f</span> GBK <span style="color: #660033;">-t</span> UTF8 <span style="color: #660033;">-r</span> <span style="color: #660033;">--notest</span> target</pre></div></div>

<p>其中-f是源编码，-t是目标编码，-r是递归处理目录，&#8211;notest是不移动，实际上对文件进行改名（actually do rename the files），target是目标目录。其余参数可以参考man或者-h。</p>
<p>另外一个方案是google到了一个python脚本，通过python的tarfile包解决问题，感兴趣的可以看看这个link: <a href="http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem" target="_blank" onclick="pageTracker._trackPageview('/outgoing/superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem?referer=');">http://superuser.com/questions/60379/linux-zip-tgz-filenames-encoding-problem</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/convmv-linux-convert-filename-encoding.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DoubanFM-CLI</title>
		<link>http://vifix.cn/blog/doubanfm-cli.html</link>
		<comments>http://vifix.cn/blog/doubanfm-cli.html#comments</comments>
		<pubDate>Wed, 12 Oct 2011 09:14:36 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2158</guid>
		<description><![CDATA[嗯……一直想在Linux下面搞个好使的豆瓣FM客户端好在工作时听听（不然要专门开个浏览器），于是google了下找到了这个，于是什么桌面客户端之类的弱爆了啊，这个才是Geeker听音乐的方式 = 。 = 东西是Python写的，代码短小精干，也可以自己研究下 github: https://github.com/zhendi/DoubanFM-CLI 作者豆瓣: http://www.douban.com/people/KaKa9527/]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/10/douban_cli.png" rel="shadowbox[sbpost-2158];player=img;" title="douban_cli"><img class="alignnone size-medium wp-image-2160" title="douban_cli" src="http://vifix.cn/blog/wp-content/uploads/2011/10/douban_cli-300x187.png" alt="" width="300" height="187" /></a></p>
<p>嗯……一直想在Linux下面搞个好使的豆瓣FM客户端好在工作时听听（不然要专门开个浏览器），于是google了下找到了这个，于是什么桌面客户端之类的弱爆了啊，这个才是Geeker听音乐的方式 = 。 =</p>
<p>东西是Python写的，代码短小精干，也可以自己研究下</p>
<p>github: <a href="https://github.com/zhendi/DoubanFM-CLI" target="_blank" onclick="pageTracker._trackPageview('/outgoing/github.com/zhendi/DoubanFM-CLI?referer=');">https://github.com/zhendi/DoubanFM-CLI</a></p>
<p>作者豆瓣: <a href="http://www.douban.com/people/KaKa9527/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.douban.com/people/KaKa9527/?referer=');">http://www.douban.com/people/KaKa9527/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/doubanfm-cli.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>fbterm—支持freetype2字体库的帧缓冲终端控制台</title>
		<link>http://vifix.cn/blog/fbterm.html</link>
		<comments>http://vifix.cn/blog/fbterm.html#comments</comments>
		<pubDate>Sat, 20 Aug 2011 18:02:18 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=2134</guid>
		<description><![CDATA[http://code.google.com/p/fbterm/ 继续来推荐Linux下面的software，这是最近发现的好物，fbterm，可以在帧缓冲的终端控制台下提供中文显示的支持，并且也能支持输入法，比起那个已经数年没有更新的zhcon好多了（zhcon也容易导致没有响应或有奇怪的问题）。更重要的是，它的字体显示是调用freetype2的，所以能和X下面的GUI应用达到相同的字体显示效果，看着文泉驿非常舒服～ 中文输入法可以用来自对岸的香草输入法，在ubuntu下面（我是11.04），需要安装的包为 libucimf fbterm-ucimf ucimf-openvanilla openvanilla-modules 装完openvanilla后可以去/usr/share/openvanilla/OVIMGeneric把文件移走到别的目录（其实就是删除），只剩拼音或者其它你熟悉的输入法～ 然后配置一下你自己的.fbtermrc，做如下设置即可： input-method=fbterm_ucimf 输入效果： PS.1: 如果不介意中文输入，也可以尝试下jfbterm这个另外的控制台终端程序，貌似也还行，就是不知道为什么我这里退出的时候程序会死掉。 PS.2:KDE 4.6的性能提升不少啊，用着很舒服，KDE加油！ PS.3: 最近工作真的是忙死了，各种求RP啊]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/08/vim.png" rel="shadowbox[sbpost-2134];player=img;" title="vim"><img class="alignnone size-medium wp-image-2135" title="vim" src="http://vifix.cn/blog/wp-content/uploads/2011/08/vim-300x187.png" alt="" width="300" height="187" /></a></p>
<p><a href="http://code.google.com/p/fbterm/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/fbterm/?referer=');">http://code.google.com/p/fbterm/</a></p>
<p>继续来推荐Linux下面的software，这是最近发现的好物，fbterm，可以在帧缓冲的终端控制台下提供中文显示的支持，并且也能支持输入法，比起那个已经数年没有更新的zhcon好多了（zhcon也容易导致没有响应或有奇怪的问题）。更重要的是，它的字体显示是调用freetype2的，所以能和X下面的GUI应用达到相同的字体显示效果，看着文泉驿非常舒服～</p>
<p><span id="more-2134"></span></p>
<p>中文输入法可以用来自对岸的香草输入法，在ubuntu下面（我是11.04），需要安装的包为</p>
<ul>
<li>libucimf</li>
<li>fbterm-ucimf</li>
<li>ucimf-openvanilla</li>
<li>openvanilla-modules</li>
</ul>
<p>装完openvanilla后可以去/usr/share/openvanilla/OVIMGeneric把文件移走到别的目录（其实就是删除），只剩拼音或者其它你熟悉的输入法～</p>
<p>然后配置一下你自己的.fbtermrc，做如下设置即可：</p>
<blockquote><p>input-method=fbterm_ucimf</p></blockquote>
<p>输入效果：</p>
<p><a href="http://vifix.cn/blog/wp-content/uploads/2011/08/w3m-img.png" rel="shadowbox[sbpost-2134];player=img;" title="w3m-img"><img class="alignnone size-medium wp-image-2136" title="w3m-img" src="http://vifix.cn/blog/wp-content/uploads/2011/08/w3m-img-300x187.png" alt="" width="300" height="187" /></a></p>
<p>PS.1: 如果不介意中文输入，也可以尝试下jfbterm这个另外的控制台终端程序，貌似也还行，就是不知道为什么我这里退出的时候程序会死掉。</p>
<p>PS.2:KDE 4.6的性能提升不少啊，用着很舒服，KDE加油！</p>
<p>PS.3: 最近工作真的是忙死了，各种求RP啊</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/fbterm.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>wget使用ssh socks代理</title>
		<link>http://vifix.cn/blog/wget-use-socks-proxy-as-http-proxy.html</link>
		<comments>http://vifix.cn/blog/wget-use-socks-proxy-as-http-proxy.html#comments</comments>
		<pubDate>Tue, 14 Sep 2010 07:40:26 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=1557</guid>
		<description><![CDATA[在apt自动调用wget下载http://archive.canonical.com/上的一个二进制文件的时候遇到了一个问题，那就是速度太慢，然而wget又无法直接指定ssh通道建立的socks代理服务器，于是google来了这个方法解决了这个问题。 wget不支持socks代理而仅支持http/https/ftp代理，而有时候又只有ssh可以用，这时候这个两部即可完成的技巧就很管用： 用ssh的-L参数指定一个端口到目标服务器的SSH Tunnel 将wget的http代理设置为localhost的对应端口，并增加一个http header 实际操作，指定端口转发到目标服务器，并和ssh服务器建立连接： ssh -L 8888:&#91;要访问的服务器IP&#93;:&#91;服务器HTTP端口&#93; &#91;ssh服务器地址&#93; 使用wget时则需要： wget -header=&#34;Host: [要访问的服务器IP]:[服务器HTTP端口]&#34; http://localhost:8888/&#91;文件路径&#93; 如果是apt那种应用环境自动调用的wget，则可以在/etc/wgetrc里面修改参数，加入 header = Host: [要访问的服务器IP]:[服务器HTTP端口] http_proxy = http://localhost:8888/]]></description>
			<content:encoded><![CDATA[<p>在apt自动调用wget下载http://archive.canonical.com/上的一个二进制文件的时候遇到了一个问题，那就是速度太慢，然而wget又无法直接指定ssh通道建立的socks代理服务器，于是google来了这个方法解决了这个问题。<br />
wget不支持socks代理而仅支持http/https/ftp代理，而有时候又只有ssh可以用，这时候这个两部即可完成的技巧就很管用：</p>
<ol>
<li>用ssh的-L参数指定一个端口到目标服务器的SSH Tunnel</li>
<li>将wget的http代理设置为localhost的对应端口，并增加一个http header</li>
</ol>
<p>实际操作，指定端口转发到目标服务器，并和ssh服务器建立连接：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">8888</span>:<span style="color: #7a0874; font-weight: bold;">&#91;</span>要访问的服务器IP<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #7a0874; font-weight: bold;">&#91;</span>服务器HTTP端口<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">ssh</span>服务器地址<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>使用wget时则需要：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-header</span>=<span style="color: #ff0000;">&quot;Host: [要访问的服务器IP]:[服务器HTTP端口]&quot;</span> http:<span style="color: #000000; font-weight: bold;">//</span>localhost:<span style="color: #000000;">8888</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>文件路径<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>如果是apt那种应用环境自动调用的wget，则可以在/etc/wgetrc里面修改参数，加入</p>
<blockquote><p>header = Host: [要访问的服务器IP]:[服务器HTTP端口]<br />
http_proxy = http://localhost:8888/</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/wget-use-socks-proxy-as-http-proxy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux批量修改多个文件名</title>
		<link>http://vifix.cn/blog/linux_renames-multiple-files.html</link>
		<comments>http://vifix.cn/blog/linux_renames-multiple-files.html#comments</comments>
		<pubDate>Mon, 06 Apr 2009 11:57:53 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=820</guid>
		<description><![CDATA[今天需要在服务器上用正则表达式来替换许多文件名中的某些字符。 于是google了&#8221;linux 批量改名&#8221;，发现rename这个工具可以满足需求，然而Google到的rename的中文说明发现它们所描述的内容已经不符合现在的版本而无法使用，所以研究了一下（也只是man rename罢了）记录下来： rename &#91; -v &#93; &#91; -n &#93; &#91; -f &#93; perlexpr &#91; files &#93; 这其中：-v 如果指定，则在屏幕回显修改的文件名 -n 如果指定，则不对文件名实际修改仅显示修改结果（测试用） -f 如果指定，则强制覆盖已有文件 perlexpr 一个Perl风格的正则表达式 files 文件名通配符 示例： rename s/_/-/ *.jpg #修改所有的包含_的.jpg文件中的_为-]]></description>
			<content:encoded><![CDATA[<p><a href="http://vifix.cn/blog/wp-content/uploads/2009/04/terminal.png" rel="shadowbox[sbpost-820];player=img;" title="terminal"><img class="alignnone size-full wp-image-821" title="terminal" src="http://vifix.cn/blog/wp-content/uploads/2009/04/terminal.png" alt="terminal" width="128" height="128" /></a></p>
<p>今天需要在服务器上用正则表达式来替换许多文件名中的某些字符。</p>
<p>于是google了&#8221;linux 批量改名&#8221;，发现rename这个工具可以满足需求，然而Google到的rename的中文说明发现它们所描述的内容已经不符合现在的版本而无法使用，所以研究了一下（也只是man rename罢了）记录下来：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rename <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-v</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> perlexpr <span style="color: #7a0874; font-weight: bold;">&#91;</span> files <span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>这其中：<code>-v 如果指定，则在屏幕回显修改的文件名<br />
-n 如果指定，则不对文件名实际修改仅显示修改结果（测试用）<br />
-f 如果指定，则强制覆盖已有文件<br />
perlexpr 一个Perl风格的正则表达式<br />
files 文件名通配符</code><br />
示例：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rename s<span style="color: #000000; font-weight: bold;">/</span>_<span style="color: #000000; font-weight: bold;">/</span>-<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">*</span>.jpg  <span style="color: #666666; font-style: italic;">#修改所有的包含_的.jpg文件中的_为-</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/linux_renames-multiple-files.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>控制台BT客户端——CTorrent</title>
		<link>http://vifix.cn/blog/console-bittorrent-client-ctorrent.html</link>
		<comments>http://vifix.cn/blog/console-bittorrent-client-ctorrent.html#comments</comments>
		<pubDate>Sat, 24 Jan 2009 07:00:20 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=618</guid>
		<description><![CDATA[今天因为一些原因希望下载一个已经没啥种子的torrent，想到了借用VPS的力量（主要是高带宽优势和区域优势），所以在VPS先安装了一个官方bittorrent，结果装出来一堆命令真是让人眼花了，觉得没爱，继续google之后，决定尝试一下这个CTorrent，使用了一下觉得临时对付一下还是十分方便的～（在Ubuntu上，apt上的已经是CTorrent的修改版——Enhanced CTorrent） 命令范例： ctorrent -s /temp -e 1 -C 32 -p 7777 test.torrent 其中-s参数指定存储路径，-e指定做种时间（单位小时），-C缓存容量（单位M），-p绑定端口，开启后会显示上传和下载的详细信息： Listening on 0.0.0.0:7777 Press 'h' or '?' for help (display/control client options). / 25/75/1589 [618/1719/1719] 156MB,46MB &#124; 226,54K/s &#124; 224,16K E:0,1 另外还可以使用-d参数进入后台运行的模式（运用fork实现），-h查看帮助～ 原作者自称为YuHong，看来是个中国人，支持一下！ Enhanced CTorrent CTorrent官方网站（项目已经停止更新） 作者本人在FreeBSD China论坛的发布帖 某人写的一篇CTorrent源码解读]]></description>
			<content:encoded><![CDATA[<p>今天因为一些原因希望下载一个已经没啥种子的torrent，想到了借用VPS的力量（主要是高带宽优势和区域优势），所以在VPS先安装了一个官方bittorrent，结果装出来一堆命令真是让人眼花了，觉得没爱，继续google之后，决定尝试一下这个CTorrent，使用了一下觉得临时对付一下还是十分方便的～（在Ubuntu上，apt上的已经是CTorrent的修改版——Enhanced CTorrent）</p>
<p>命令范例：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ctorrent <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>temp <span style="color: #660033;">-e</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-C</span> <span style="color: #000000;">32</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">7777</span> test.torrent</pre></div></div>

<p>其中-s参数指定存储路径，-e指定做种时间（单位小时），-C缓存容量（单位M），-p绑定端口，开启后会显示上传和下载的详细信息：</p>
<pre>Listening on 0.0.0.0:7777
Press 'h' or '?' for help (display/control client options).
/ 25/75/1589 [618/1719/1719] 156MB,46MB | 226,54K/s | 224,16K E:0,1</pre>
<p>另外还可以使用-d参数进入后台运行的模式（运用fork实现），-h查看帮助～</p>
<p>原作者自称为YuHong，看来是个中国人，支持一下！</p>
<p><a href="http://www.rahul.net/dholmes/ctorrent/" onclick="pageTracker._trackPageview('/outgoing/www.rahul.net/dholmes/ctorrent/?referer=');">Enhanced CTorrent</a></p>
<p><a href="http://ctorrent.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/ctorrent.sourceforge.net/?referer=');">CTorrent官方网站（项目已经停止更新）</a></p>
<p><a href="http://www.freebsdchina.org/forum/viewtopic.php?p=39082" onclick="pageTracker._trackPageview('/outgoing/www.freebsdchina.org/forum/viewtopic.php?p=39082&amp;referer=');">作者本人在FreeBSD China论坛的发布帖</a></p>
<p><a href="http://yaoxuchen.googlepages.com/ctorrent" onclick="pageTracker._trackPageview('/outgoing/yaoxuchen.googlepages.com/ctorrent?referer=');">某人写的一篇CTorrent源码解读</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/console-bittorrent-client-ctorrent.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Linux批量替换多文件文本</title>
		<link>http://vifix.cn/blog/linux%e6%89%b9%e9%87%8f%e6%9b%bf%e6%8d%a2%e5%a4%9a%e6%96%87%e4%bb%b6%e6%96%87%e6%9c%ac.html</link>
		<comments>http://vifix.cn/blog/linux%e6%89%b9%e9%87%8f%e6%9b%bf%e6%8d%a2%e5%a4%9a%e6%96%87%e4%bb%b6%e6%96%87%e6%9c%ac.html#comments</comments>
		<pubDate>Wed, 17 Dec 2008 06:24:12 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=367</guid>
		<description><![CDATA[将某目录中所有文件中的文本“abcde”替换成“vifix”： 1.sed+grep方案： sed -i &#34;s/abcde/vifix/g&#34; `grep abcde -rl /home/test` 2.perl方案： perl -p -i -e &#34;s/abcde/vifix/g&#34; * update @2011-11-10: 3. sed+find方案： find -iname &#34;*.txt&#34; -exec sed -i &#34;s/from_string/to_string/g&#34; &#123;&#125; \;]]></description>
			<content:encoded><![CDATA[<p>将某目录中所有文件中的文本“abcde”替换成“vifix”：</p>
<p>1.sed+grep方案：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;s/abcde/vifix/g&quot;</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">grep</span> abcde <span style="color: #660033;">-rl</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span><span style="color: #000000; font-weight: bold;">`</span></pre></div></div>

<p>2.perl方案：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/abcde/vifix/g&quot;</span> <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p><strong>update @2011-11-10:</strong><br />
3. sed+find方案：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #660033;">-iname</span> <span style="color: #ff0000;">&quot;*.txt&quot;</span> <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;s/from_string/to_string/g&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/linux%e6%89%b9%e9%87%8f%e6%9b%bf%e6%8d%a2%e5%a4%9a%e6%96%87%e4%bb%b6%e6%96%87%e6%9c%ac.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CMD批处理大量隐藏+系统+只读属性的文件夹</title>
		<link>http://vifix.cn/blog/cmd%e6%89%b9%e5%a4%84%e7%90%86%e5%a4%a7%e9%87%8f%e9%9a%90%e8%97%8f%e7%b3%bb%e7%bb%9f%e5%8f%aa%e8%af%bb%e5%b1%9e%e6%80%a7%e7%9a%84%e6%96%87%e4%bb%b6%e5%a4%b9.html</link>
		<comments>http://vifix.cn/blog/cmd%e6%89%b9%e5%a4%84%e7%90%86%e5%a4%a7%e9%87%8f%e9%9a%90%e8%97%8f%e7%b3%bb%e7%bb%9f%e5%8f%aa%e8%af%bb%e5%b1%9e%e6%80%a7%e7%9a%84%e6%96%87%e4%bb%b6%e5%a4%b9.html#comments</comments>
		<pubDate>Sun, 30 Nov 2008 02:24:10 +0000</pubDate>
		<dc:creator>Mac</dc:creator>
				<category><![CDATA[Atelier]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://vifix.cn/blog/?p=228</guid>
		<description><![CDATA[嘛，近来有病毒批量修改USB存储设备的文件夹属性，设置为&#8221;系统&#8221; + &#8220;隐藏&#8221; + &#8220;只读&#8221;，给使用带来巨大不便，消灭病毒后手动恢复这些属性也十分麻烦。 稍微研究了一下批处理的for的用法，写了这个批处理，遍历所有当前目录下的隐藏目录，并且取消&#8221;系统&#8221;/&#8221;隐藏&#8221;/&#8221;只读&#8221;的属性。 FOR /f &#34;delims=&#34; %%i IN ('dir /b /s /a:dh') DO ( ECHO %%i ATTRIB -s -h -r &#34;%%i&#34; ) PAUSE 把以上内容保存为.bat或者.cmd，在需要的目录下执行即可（一般是移动硬盘/U盘根目录）]]></description>
			<content:encoded><![CDATA[<p>嘛，近来有病毒批量修改USB存储设备的文件夹属性，设置为&#8221;系统&#8221; + &#8220;隐藏&#8221; + &#8220;只读&#8221;，给使用带来巨大不便，消灭病毒后手动恢复这些属性也十分麻烦。<br />
稍微研究了一下批处理的for的用法，写了这个批处理，遍历所有当前目录下的隐藏目录，并且取消&#8221;系统&#8221;/&#8221;隐藏&#8221;/&#8221;只读&#8221;的属性。</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;"><span style="color: #00b100; font-weight: bold;">FOR</span> /f &quot;delims=&quot; <span style="color: #33cc33;">%%</span><span style="color: #448888;">i</span> <span style="color: #00b100; font-weight: bold;">IN</span> <span style="color: #33cc33;">(</span>'<span style="color: #b1b100; font-weight: bold;">dir</span> /b /s /a:dh'<span style="color: #33cc33;">)</span> <span style="color: #00b100; font-weight: bold;">DO</span> <span style="color: #33cc33;">(</span>
 <span style="color: #b1b100; font-weight: bold;">ECHO</span> <span style="color: #33cc33;">%%</span><span style="color: #448888;">i</span>
 ATTRIB -s -h -r &quot;<span style="color: #33cc33;">%%</span><span style="color: #448888;">i</span>&quot;
<span style="color: #33cc33;">)</span>
<span style="color: #b1b100; font-weight: bold;">PAUSE</span></pre></div></div>

<p>把以上内容保存为.bat或者.cmd，在需要的目录下执行即可（一般是移动硬盘/U盘根目录）</p>
]]></content:encoded>
			<wfw:commentRss>http://vifix.cn/blog/cmd%e6%89%b9%e5%a4%84%e7%90%86%e5%a4%a7%e9%87%8f%e9%9a%90%e8%97%8f%e7%b3%bb%e7%bb%9f%e5%8f%aa%e8%af%bb%e5%b1%9e%e6%80%a7%e7%9a%84%e6%96%87%e4%bb%b6%e5%a4%b9.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

