Reputation: 2180
I have a file with many lines, with lines such as so:
PHP_VERSION="5.3.12"
NPM_VERSION="1.10"
From a linux command line, how would I take out just the version number? For this example, how would I get an output like 5.3.12
if for say I wanted the PHP version out of the given input file.
Upvotes: 0
Views: 58
Reputation: 718
Your trying to get it with bash
?
. /path/to/file
echo $PHP_VERSION
?
Upvotes: 3
Reputation: 623
I would use something like:
var="$(grep -F -m 1 '$variable =' file)"; var="${var#*\'}"; var="${var%\'*}"
Reference: BASH shell use regex to get value from file into a parameter
Upvotes: 2