Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The great FART utility seems to be the norm when trying to replace text on the windows command line.

However I can't get it to work as shown in the examples. My test file test.txt:

Images Here Images

I now try this:

fart -r -i -p "test.txt" "Images"

and get:

Images Here Images
Found 4 occurence(s) in 1 file(s).

Great! But when now trying to replace Images with Foo it won't work:

fart -r -i -p "test.txt" "Images" "foo"
--> Replaced 0 occurence(s) in 1 file(s).

Everyone seems to just do a fart -r -i- p <filename> <string_to_replace> <replacement> command and work with it. What am I doing wrong?

share|improve this question
Fart and rip? This is my new favorite software! – iglvzx May 8 '12 at 9:31
you can also just do -rip to make it clearer what you're trying to say – Dennis G May 8 '12 at 9:34
perl -p -i -e 's/Image/foo/' test.txt leaves you smelling nicer. – RedGrittyBrick May 8 '12 at 10:00
And requires me to install 32MB perl. Even though I like pie. – Dennis G May 8 '12 at 10:04
Also Powershell: $filename = $args[0] $search = $args[1] $replace = $args[2] (Get-Content $filename) | Foreach-Object {$_ -replace "$search", "$replace"} | Set-Content $filename – Dennis G May 8 '12 at 10:10
up vote 2 down vote accepted

Is this a trick question? FART's usage help clearly states that -p stands for "preview", so if you remove it the changes will actually be made.

(Also, -r isn't required if you're only dealing with a single file.)

share|improve this answer
My first good laugh today :] – nixda Jan 6 '13 at 19:29
Now that was an easy solution. No joke here, I used PowerShell anyways. Thanks for the find :-) – Dennis G Jan 6 '13 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .