Functions
| Function | Description | Example |
|---|---|---|
os.read(path) | Read file contents | os.read("config.txt") |
os.write(path, content) | Write string to file | os.write("out.txt", "hello") |
os.append(path, content) | Append to file | os.append("log.txt", "entry\n") |
os.exists(path) | Check if file/dir exists | os.exists("config.txt") → true |
os.delete(path) | Delete a file | os.delete("temp.txt") |
os.mkdir(path) | Create directory | os.mkdir("output") |
os.list(path) | List directory contents | os.list(".") → ["file1", "dir1"] |
os.cwd() | Current working directory | os.cwd() → "/home/alex/project" |
os.env(key) | Get environment variable | os.env("HOME") |