How to get Erlang's release version number from a shell?

 erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().'  -noshell

The other answers only display major version as of OTP 17 (from docs for erlang:system_info). This works to display major and minor version on my development machine:

erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell

This reads from the appropriate file, as described in the docs.


(I'm adding this answer here since I've searched for this at least 3 times in the past three months)

Starting from version 17.0 releases have a new format in their version number (17.0, 17.1, ...) but erlang:system_info(otp_release). only returns the major version number.

In order to get the full version number it is necessary to check the contents of the OTP_RELEASE file under the already mentioned releases folder.

$ which erl
/usr/bin/erl
$ cd /usr/bin
$ ls -l erl
../lib/erlang/bin/erl
$ cd ../lib/erlang/
$ cat releases/17/OTP_RELEASE
17.3

EDIT

# Some versions seem to have OTP_VERSION instead of OTP_RELEASE
$ cat releases/17/OTP_VERSION
17.4

Tags:

Shell

Erlang

Otp