How do I get a part of the output of a command in Bash?
For example, the command php -v outputs:
php -v
PHP 5.3.28 (cli) (built: Jun 23 2014 16:25:09
In pure Bash you can do
echo 'PHP 5.3.28 (cli) (built: Jun 23 2014 16:25:09)' | cut -d '(' -f 1,2
Output:
PHP 5.3.28 (cli)
Or using space as the delimiter:
echo 'PHP 5.3.28 (cli) (built: Jun 23 2014 16:25:09)' | cut -d ' ' -f 1,2,3