RingToFile = fun(InputFile,OutputFile) ->
{ok,Data} = file:read_file(InputFile),
T = binary_to_term(Data),
{ok,Handle} = file:open(OutputFile,[write,append]),
Line = io_lib:format("~p", [T]),
file:write(Handle, Line),
file:close(Handle)
end.
Example usage
10> RingToFile("./riak_core_ring.default.20150625091718","/tmp/ring.txt").
ok
ZSH.. generating a bunch of commands to run from Erlang:
for i in **/ring*/*def*(.:a); do echo "RingToFile(\"$i\",\"/tmp/$(echo $i | sed 's_.*/__g')\")." ; done
Result:
RingToFile("/Users/bryanhunt/upload.basho.com/foo/[email protected]/[email protected]/ring/riak_core_ring.default.20150707050339",
"/tmp/riak_core_ring.default.20150707050339").
RingToFile("/Users/bryanhunt/upload.basho.com/foo/[email protected]/[email protected]/ring/riak_core_ring.default.20150707050339
","/tmp/riak_core_ring.default.20150707050339").
RingToFile("/Users/bryanhunt/upload.basho.com/foo/[email protected]/[email protected]/ring/riak_core_ring.default.20150707050339
","/tmp/riak_core_ring.default.20150707050339").
RingToFile("/Users/bryanhunt/upload.basho.com/foo/[email protected]/[email protected]/ring/riak_core_ring.default.20150707050339
","/tmp/riak_core_ring.default.20150707050339").
RingToFile("/Users/bryanhunt/upload.basho.com/foo/[email protected]/[email protected]/ring/riak_core_ring.default.20150707050339",
"/tmp/riak_core_ring.default.20150707050339").