Como executar o comando java jshell como embutido no shell ou no comando do Windows
Existe alguma maneira de executar o comando java no REPL (jshell
) como comando embutido sem iniciá-lo?
Por exemplo. Comando Perl Inline
$perl -e 'printf("%06d", 19)'
000019
Eu tenho que iniciar o jshell para executar qualquer comando:
$jshell
| Welcome to JShell -- Version 9
| For an introduction type: /help intro
jshell> String.format("%06d", 19)
$1 ==> "000019"
Eu encontrei pergunta semelhanteaqui, mas não é possível criar uma solução separadajsh
arquivo para comando individual.
Outra solução no mesmo post é:echo "1+2"|jshell
temp=`echo 'String.format("%06d", 19)'|jshell`
echo $temp
Ouch output
| Welcome to JShell -- Version 9 | For an introduction type: /help intro jshell> String.format("%06d", 19) $1 ==> "000019" jshell>
Estou esperando$temp
apenas imprima000019
.