local filename = ...; assert(filename); local infile = assert(io.open("infile", "r")) local contents = infile:read("*all") print(contents) io.stdout:write("> ") local command = io.stdin:read("*line") local delimiter = string.sub(command, 1, 1) local other_delimiter = string.find(command, delimiter, 2) local pattern = string.sub(command, 2, other_delimiter - 1) local substitute = string.sub(command, other_delimiter + 1) contents = string.gsub(contents, pattern, substitute, 1) local outfile = assert(io.open("outfile", "w")) outfile:write(contents) outfile:close()