Create a new file in Lua / LuaFileSystem

I looked through the Lua and LuaFileSystem documents and have not yet found a way to create a new file, I also searched here, but at the same end.

As a side note, the solution I'm looking for should be neutral for portability, but I'm glad to get different answers for different systems.

+5
source share
1 answer

Example (write "Hello World" in test.txt):

$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> file = io.open("test.txt", "w")
> file:write("Hello World")
> file:close()
> ^D
$ cat test.txt 
Hello World

See also: Lua IO Tutorial

+20
source

All Articles