To Get the current Magento version string using getVersion function inside the Mage.php file.
Run the following command in terminal
php -r "include 'app/Mage.php'; echo 'Magento version is: ', Mage::getVersion(); "
For example:
#cd /home/cp_user/public_html/
# php -r "include 'app/Mage.php'; echo 'Magento version is: ', Mage::getVersion(); "
Magento version is: 1.9.2.2