bash - Get java version in csh (c shell) -
i need java version using c-shell script. i'll need put variable , use afterwards manipulations , tests. in bash command works:
local javaversion=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
but in c-shell, when try:
set javaversion=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
i
"ambiguous output redirect."
error.
yes, have in c-shell, not bash or other language.
i searched , other forums in internet didn't find helpful.
thanks.
here way should works me:
> set javaversion=`java -version |& sed 's/.* version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q'` > echo $javaversion 18
changes are:
replace
$( command )
`command`
; former recommended current posix shell syntax has never been implementedcsh
.replace
2>&1 |
|&
; former bourne shell specific, lattercsh
specific.replace
java version
.* version
; not strictly necessary eased testsjava -version
returnsopenjdk version...
on machine, notjava version...
Comments
Post a Comment