RosettaCodeData/Task/Globally-replace-text-in-several-files/Lua/globally-replace-text-in-several-files.lua
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

12 lines
278 B
Lua

filenames = { "f1.txt", "f2.txt" }
for _, fn in pairs( filenames ) do
fp = io.open( fn, "r" )
str = fp:read( "*all" )
str = string.gsub( str, "Goodbye London!", "Hello New York!" )
fp:close()
fp = io.open( fn, "w+" )
fp:write( str )
fp:close()
end