How to empty a file

,

You can use the Erlang file module function position/2 and truncate/1 to set the position at the beginning of the file and truncate it:

file |> :file.position(:bof) |> :file.truncate()
2 Likes