Jump to content

Globally replace text in several files: Difference between revisions

newLISP solution
(newLISP solution)
Line 904:
Bye bye London! Bye bye London!
</pre>
 
=={{header|newLISP}}==
{works with|newLisp|10.7.5}}
<lang newLISP>
(define (replace-in-file filename this bythat)
(set 'content (read-file filename))
(when (string? content)
(replace this content bythat)
(write-file filename content)
)
)
 
(set 'files '("a.txt" "b.txt" "c.txt" "missing"))
(dolist (fname files)
(replace-in-file fname "Goodbye London!" "Hello New York!")
)
 
(exit)
</lang>
 
=={{header|Nim}}==
Line 913 ⟶ 932:
for fn in ["a.txt", "b.txt", "c.txt"]:
fn.writeFile fn.readFile.replace(fr, to)</lang>
 
 
=={{header|Objeck}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.