惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
小众软件
小众软件
I
InfoQ
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
月光博客
月光博客
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
V
Visual Studio Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
GbyAI
GbyAI
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - Mamboer

[IE6]IE6:hover失效 html5文件上传-iis7报奇怪的404(NotFound)错误 Editplus-关联yuicompressor进行JS和CSS的压缩 ubuntu-安装aptana3 Ubuntu-环境配置文件 Ubuntu安装Git客户端 Ubuntu安装Chrome最新版 ubuntu-restricted-extras 高效率编辑器VIM-操作篇 Ubuntu安装雅黑字体 试用Opera11.10 build2053 版本的speed dial功能 Building Vim on Ubuntu Ubuntu安装Mercurial utf-8格式之no bom和+bom [PM]-组织者角色 IE6问题Q&A,你懂的... Logo一个-小凡设计 正则表达式-用户名规则之只含汉字、数字、字母、下划线 如何bin部署sqlce4.0的ASP.NET mvc3网站
Windows Command Line Find and replace - Made easy with FA...
Mamboer · 2011-08-24 · via 博客园 - Mamboer

Windows Command Line Find and replace - Made easy with FART.exe

Here is a great little application that does a find and replace on a particular file, file type or file contents, then replaces it with a string of your choice. It can look in sub directories as well.
The small app is called FART, yes that’s right FART - Find And Replace Text!

Usage: FART [options] [--] 

[,...] [find_string] [replace_string]

Options

  • -h, –help Show this help message (ignores other options)
  • -q, –quiet Suppress output to stdio / stderr
  • -V, –verbose Show more information
  • -r, –recursive Process sub-folders recursively
  • -c, –count Only show filenames, match counts and totals
  • -i, –ignore-case Case insensitive text comparison
  • -v, –invert Print lines NOT containing the find string
  • -n, –line-number Print line number before each line (1-based)
  • -w, –word Match whole word (uses C syntax, like grep)
  • -f, –filename Find (and replace) filename instead of contents
  • -B, –binary Also search (and replace) in binary files (CAUTION)
  • -C, –c-style Allow C-style extended characters (\xFF\t\n\r\\ etc.)
  • –cvs Skip cvs dirs; execute “cvs edit” before changing files
  • –svn Skip svn dirs
  • –remove Remove all occurences of the find_string
  • -a, –adapt Adapt the case of replace_string to found string
  • -b, –backup Make a backup of each changed file
  • -p, –preview Do not change the files but print the changes

Example 1 (replace text, preview only)

fart -c -r -i -p *.txt original_text new_text

This will look for all .txt files in a sub directory, locate the original_text string within the .txt file and change it to new_text. The -p switch means it won't actually change anything because this is a preview, showing you how many strings it found within each .txt file.

Example 2 (replace text)

fart -c -r -i *.txt original_text new_text

Same as above except it will do the actual replacement.

Example 3 (remove text)

fart -r -i --remove *.txt "remove this text"

Rather than replacing one term for another this will remove the specified term.

NOTE: Use quotes around text if it contains spaces, tabs, etc.

Download FART from SourceForge.