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
If you want all the lines that contain "php", do this:
$ php -v | grep -i "php"
Then if you want the first three words within those, you can add another pipe as @Avinash suggested:
$ php -v | grep -i "php" | awk 'NR==1{print $1,$2,$3}'