I am writing a script server automation using Chef and I need to check the installed version of the PEAR package manager. The -V command line switch prints detailed version information to the console:
PEAR Version: 1.9.0 PHP Version: 5.3.5-1ubuntu7.2ppa1~lucid Zend Engine Version: 2.3.0 Running on: Linux ubuntu-lucid-32-generic 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:08:37 UTC 2011 i686
However, I can not isolate 1.9.0 part of this result and test it. The pear script does not seem to print in STDOUT, since the redirect also does not work:
$ pear -V > pear_version PEAR Version 1.9.0 ... $ cat pear_version $
How can I capture the output and pass it grep so that I can only return "1.9.0"?
source share