Cómo ejecutar el comando java jshell como en línea desde el shell o la línea de comandos de Windows
¿Hay alguna forma de ejecutar el comando java en REPL (jshell
) como comando en línea sin iniciarlo?
P.ej. Comando en línea Perl
$perl -e 'printf("%06d", 19)'
000019
Tengo que iniciar jshell para ejecutar cualquier comando:
$jshell
| Welcome to JShell -- Version 9
| For an introduction type: /help intro
jshell> String.format("%06d", 19)
$1 ==> "000019"
Encontré una pregunta similaraquí, pero no es una solución factible crear unjsh
archivo para comando individual.
Otra solución en la misma publicación es:echo "1+2"|jshell
temp=`echo 'String.format("%06d", 19)'|jshell`
echo $temp
Ouch salida
| Welcome to JShell -- Version 9 | For an introduction type: /help intro jshell> String.format("%06d", 19) $1 ==> "000019" jshell>
Estoy esperando$temp
solo imprimir000019
.