先前用过了,省得自己不记得,好记性不如烂笔头。记下吧。
将某目录中所有文件中的文本“abcde”替换成“12345”:
1.sed方案:
1 |
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">"s/abcde/12345/g"</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;">/path</span><span style="color: #7a0874; font-weight: bold;"></span><span style="color: #000000; font-weight: bold;">`</span> |
2.perl方案:
1 2 3 4 5 6 7 |
<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;">"s/abcde/12345/g"</span> <span style="color: #000000; font-weight: bold;">* 另 文件批量改名rename也相通 如 rename </span> <pre class="bash" style="font-family: monospace;">rename s<span style="color: #000000; font-weight: bold;">/</span>x<span style="color: #000000; font-weight: bold;">/</span>y<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">*</span>.abc <span style="color: #666666; font-style: italic;">#修改所有的包含_的.abc文件中的x为y</span> |
文章评论
不错的小技巧
@longines 呵呵,难道是搜索过来的。用的上就行。
我哪最近多了很多垃圾评论。为啥呢..
@julf 垃圾评论泛滥总是1段段的。Akismet用上了没。
没AIP KEY
@julf 还是要申请一个key. \nYou are using WordPress 2.7.1.\n\nAkismet has protected your site from 1,725 spam comments already
能申请,我还说啊..汗
@julf 都能申请吧,难道是wordpress.com被墙的问题,找代理啊,哈哈。要不用ssh空间自己tunnel一下.