FART: easy grep-like utility for Windows

The Find And Replace Text utility is a handy little command-line tool to have if you’re a Windows user. It can function as a simple grep-like utility for quickly searching through whole directories of files, and you can also use it to perform mass search and replace operations on a file or group of files.

The command format is fart <options> filename search <replace>. Basic options are -r (recursive), -c (print filename and match count), -i (ignore case), -n (print matched line numbers), –c-style (interpret backslashes as c-style characters).

For example, let’s say a Linux buddy of yours sent you a bunch of html files and they have unix line endings that are barfing in notepad. One simple command fixes the problem, replacing all the newlines with a full PC carriage return, line feed combo:

fart --c-style *.html

Or perhaps you need to quickly track down some work that is left to be done throughout a big project directory. You can use fart to recursively search a directory and spit out all the file names and line numbers containing the text “TODO”:

fart -nr * TODO

It’s easy to see how you could shoot yourself in the foot with this one. Make sure to fart with caution and back up your files before doing a big search and replace.

FART @ SourceForge – Link

5 Responses to FART: easy grep-like utility for Windows

  1. Mihai Criveti on said:

    Try “findstr”, it does Regular Expressions. Part of Windows too :-) .

    C:WindowsSystem32findstr.exe -?
    [..]

    Regular expression quick reference:
    . Wildcard: any character
    * Repeat: zero or more occurrences of previous character or class
    ^ Line position: beginning of line
    $ Line position: end of line
    [class] Character class: any one character in set
    [^class] Inverse class: any one character not in set
    [x-y] Range: any characters within the specified range
    x Escape: literal use of metacharacter x
    Word position: end of word

  2. Andy Lester on said:

    ack is also a good choice for Windows. It’s pure Perl, uses Perl regular expressions, and is well-supported.

    http://petdance.com/ack/

  3. How does this compare to mtr? on said:

    How does this program differ from MiniTrue? http://www.student.northpark.edu/pemente/sed/minitrue.htm

  4. Mahmudul Hasan on said:

    Fart is cool.

    Findstr is a powerfull tool i know. But fart is very handy for certain jobs, for which findstr will take a lengthier command.

    Mahmudul Hasan

  5. TomasV on said:

    This looks like a nice tool, but a RegEx search and REPLACE command-line utility would be nice (which the above mentioned aren’t). Is there even any (for Windows)? It’s planned for FART based on the info on th SF.net page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s