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

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.

转载于:https://www.cnblogs.com/mamboer/archive/2011/08/24/find-and-replace-using-fart-exe.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值