Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
ImagesWhateverImages

I now try this:

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

and get:

Images Here Images
ImagesWhateverImages
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
3  
Fart and rip? This is my new favorite software! –  iglvzx May 8 '12 at 9:31
1  
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
1  
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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.