Erlang Central

Print Untruncated Terms In The Shell

From ErlangCentral Wiki

Overview

While in the shell, I frequently need to view some large term (let's call it X) such as a deep list. The shell usually truncates such a term. At this point many people, muttering darkly, are forced to type in io:format("~p\n", [X]). Isn't there a better way? As it turns out, yes: use the built-in shell function rp(Term). This is used to "display a Term using the shell's record information", according to the shell's help() function, but works for any Erlang term and has the side-effect of expanding the term fully.

Example

1> mnesia:start(), X = mnesia:system_info(all).
[{access_module,mnesia},
 {auto_repair,true},
 %% ++++ .... rows deleted for brevity ...
 {schema_location,opt_disc},
 {schema_version,...},
 {...}|...] %% Arghhh!!!!

2> rp(X).
[{access_module,mnesia},
 {auto_repair,true},
 %% ++++ .... rows deleted for brevity ...
 {schema_location,opt_disc},
 {schema_version,{2,0}},
 {subscribers,[<0.37.0>]},
 {tables,[schema]},
 {transaction_commits,2},
 {transaction_failures,0},
 {transaction_log_writes,0},
 {transaction_restarts,0},
 {transactions,[]},
 {use_dir,false},
 {core_dir,false},
 {no_table_loaders,2},
 {dc_dump_limit,4},
 {version,"4.4.3"}]

An sentence from

Dmitry Podkorytov

What about io:write(Term) ?

For example: 1> io:write(lists:seq(1,50000)).