{"id":8,"date":"2011-03-20T16:16:41","date_gmt":"2011-03-20T16:16:41","guid":{"rendered":"http:\/\/emtunc.org\/blog\/?p=8"},"modified":"2013-06-15T13:26:58","modified_gmt":"2013-06-15T12:26:58","slug":"farting-the-easy-way-find-and-replace-text","status":"publish","type":"post","link":"https:\/\/emtunc.org\/blog\/03\/2011\/farting-the-easy-way-find-and-replace-text\/","title":{"rendered":"FARTing the Easy Way &#8211; Find And Replace Text"},"content":{"rendered":"<p>Have you ever found your self in a situation where you&#8217;ve needed to replace text in multiple files quickly and efficiently?<\/p>\n<p>I came across this conundrum on a monthly basis when I needed to change the contents of tens\/hundreds of LoadRunner scripts and parameters to point from the name of the preceding month to the name of the current month.<\/p>\n<p>I did a bit of searching online and found this handy little command line utility called <a title=\"FART\" href=\"http:\/\/fart-it.sourceforge.net\/\" target=\"_blank\">FART &#8211; Find and Replace Text<\/a>. Put simply, it searches a file for X string and replaces it with Y.<\/p>\n<p>It is really easy to use and literally takes a few minutes to set-up:<\/p>\n<p><!--more--><\/p>\n<p><code>Usage: FART [options] [--] [,...] [find_string] [replace_string]<\/code><\/p>\n<p>&nbsp;<\/p>\n<p><code>Options:<br \/>\n-h --help Show this help message (ignores other options)<br \/>\n-q --quiet Suppress output to stdio \/ stderr<br \/>\n-V --verbose Show more information<br \/>\n-r --recursive Process sub-folders recursively<br \/>\n-c --count Only show filenames, match counts and totals<br \/>\n-i --ignore-case Case insensitive text comparison<br \/>\n-v --invert Print lines NOT containing the find string<br \/>\n-n --line-number Print line number before each line (1-based)<br \/>\n-w --word Match whole word (uses C syntax, like grep)<br \/>\n-f --filename Find (and replace) filename instead of contents<br \/>\n-B --binary Also search (and replace) in binary files (CAUTION)<br \/>\n-C --c-style Allow C-style extended characters (\\xFF\\0\\t\\n\\r\\\\ etc.)<br \/>\n--cvs Skip cvs dirs; execute \"cvs edit\" before changing files<br \/>\n-a --adapt Adapt the case of replace_string to found string<br \/>\n-b --backup Make a backup of each changed file<br \/>\n-p --preview Do not change the files but print the changes<\/code><\/p>\n<h3>Examples:<\/h3>\n<p><code>fart \"C:\\APRIL2011\\Scripts\\someFile.txt\" oldText newText<br \/>\n<\/code><\/p>\n<p>This line instructs FART to simply replace the string <strong>oldText<\/strong> with <strong>newText<\/strong>.<\/p>\n<p><code>fart -i -r \"C:\\APRIL2011\\Scripts\\*.prm\" march2011 APRIL2011<\/code><\/p>\n<p>This line will instruct FART to recursively (-r) search for any file with the .prm extension in the \\Scripts folder. The -i flag tells FART to ignore case-sensitivity when looking for the string.<\/p>\n<h3>Download:<\/h3>\n<p>You can download the latest version of FART (1.99b) from the <a title=\"Download FART\" href=\"http:\/\/fart-it.sourceforge.net\/\" target=\"_blank\">author&#8217;s homepage<\/a> or from <a title=\"Alternative download\" href=\"http:\/\/emtunc.org\/blog\/wp-content\/uploads\/2011\/03\/fart199b_win32.zip\" target=\"_blank\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever found your self in a situation where you&#8217;ve needed to replace text in multiple files quickly and efficiently? I came across this conundrum on a monthly basis when I needed to change the contents of tens\/hundreds of LoadRunner scripts and parameters to point from the name of the preceding month to the [&hellip;]<\/p>\n","protected":false},"author":32,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-tech"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1trTO-8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/users\/32"}],"replies":[{"embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/comments?post=8"}],"version-history":[{"count":2,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":952,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/posts\/8\/revisions\/952"}],"wp:attachment":[{"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/media?parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/categories?post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emtunc.org\/blog\/wp-json\/wp\/v2\/tags?post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}