Nov
02
2006

ex 單行指令: 處理文字檔案

以往需要從文字檔中進行 Search & Replace, 通常都會使用 PERL。

但其實使用 VIM 的 ex 模式便可作更快的處理。

刪除特定字串:

  1. echo '/delete_me/d | x!' | ex - 123.txt

 

Search & Replace:

  1. echo '%s/search/replace/g | x!' | ex - 123.txt
Written by Chris Lam in: Linux / Unix |

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes