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 implemented csh.

  • replace 2>&1 | |&; former bourne shell specific, latter csh specific.

  • replace java version .* version; not strictly necessary eased tests java -version returns openjdk version... on machine, not java version...


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -