Of course, everybody knows ‘
gcc --version‘ option to check gcc version, but output is quite verbose and is not easy to parse and use in scripts.
Luckily, gcc has option that will output gcc version in an easy-to-parse format:
$ gcc -dumpversion
This output is much easier to use in scripts in, for example, something like this:
declare -r gcc_ver=$(gcc -dumpversion)