Reputation: 1077
I'm using the following command to get java.home path
java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
the command above returns
java.home = /usr/lib/jvm/java-11-openjdk-amd64
How can I get it to only return "/usr/lib/jvm/java-11-openjdk-amd64"
Upvotes: 0
Views: 48
Reputation: 46
Just use awk to cut out the last field:
java -XshowSettings:properties -version 2>&1 >/dev/null | grep 'java.home' | awk '{print $NF}'
Or a little shorter:
java -XshowSettings:properties -version 2>&1 | awk '/java.home/ {print $NF}'
Upvotes: 2