How to create a file in Julia?

Viewed 267

Is there a quick and simple way I can create a new file (whether it be a txt or .jl file) from the REPL or in Julia script? I would usually do something like use the touch command from the terminal (even though that is designed to update the timestamp of when the file was last edited).

It looks like I can use the open function in "create" mode but I prefer to not use that syntax.

1 Answers

As it turns out, there is actually a touch function in Julia:

julia> touch("test.txt")
"test.txt"

which similar to the terminal command, is designed to allow you to update the timestamp of when the file was last modified, but if the file does not exist, the touch command will create it for you. You can read more about the touch command in the Julia docs.

Related