9951 explained code solutions for 126 technologies


luaHow to write to file


file = io.open('/tmp/hi.txt', 'w')
file:write('hello!')
io.close(file)ctrl + c
io.open

opens file handler

/tmp/hi.txt

path to file to write

'w'

open file in writing mode

file:write

write specified text to file

'hello!'

sample text to write to file

io.close

closes file handler