Redirect output from erlang shell into a file
erlang
Solution
Just run it with `erl -noinput -s module function -s init stop > file`.
Here's an example.
Erlang code:
-module(test).
-compile(export_all).
function() ->
io:fwrite("Hello world!~n").
In shell:
$ erlc test.erl
$ erl -noinput -s test function -s init stop > test.txt
$ cat test.txt
Hello world!
Problem
Is there a way to redirect data printed by `io:format()` from erlang shell into a file ? I know that I can open a file (IoDevice) and write data directly into it, but it requires code change and I don't want to do now.