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

來源:互聯網
上載者:User
Windows Command Line Find and replace - Made easy with FART.exeHere 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.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.