1 | cat pom.xml | grep "^ <version>.*</version>$" | awk -F'[><]' '{print $3}' |
Notes:
“cat pom.xml”: print the whole content of the pom.xml file;
“grep “^ <version>.*</version>$””: Get the version line of the pom.xml project. Only the project’s version line has the 4 spaces indent(for the other version lines in the dependencies section have more indent spaces. Good indent is useful here);
“awk -F’[><]’ ‘{print $3}’”: seperate the version line by “<” and “>” and get the version info only without “<version>“ or “</version>“.