- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法在 REPL (jshell
) 上执行 java 命令作为内联命令而不启动它?
例如Perl 内联命令
$perl -e 'printf("%06d", 19)'
000019
我必须启动 jshell 才能运行任何命令:
$jshell
| Welcome to JShell -- Version 9
| For an introduction type: /help intro
jshell> String.format("%06d", 19)
$1 ==> "000019"
我发现类似的问题here ,但为单个命令创建单独的 jsh
文件并不是可行的解决方案。
同一篇文章的另一个解决方案是:echo "1+2"|jshell
temp=`echo 'String.format("%06d", 19)'|jshell`
echo $temp
哎哟输出
| Welcome to JShell -- Version 9 | For an introduction type: /help intro jshell> String.format("%06d", 19) $1 ==> "000019" jshell>
我期望 $temp
只打印 000019
。
最佳答案
默认情况下,与 JShell
交互时使用正常
反馈模式,此模式打印命令输出、声明、命令和提示。阅读 Introduction to jshell feedback modes更多细节。
获取命令输出的步骤:
以简洁
反馈模式运行jshell
以跳过命令和声明细节,它仍然会打印提示和值。
$ echo 'String.format("%06d", 19)' | jshell --feedback concise
jshell> String.format("%06d", 19)
$1 ==> "000019"
使用 sed
从结果中过滤第二行-
echo 'String.format("%06d", 19)' | jshell --feedback concise | sed -n '2p'
仅提取值并排除其他详细信息-
echo 'String.format("%06d", 19)' | jshell --feedback concise | sed -n '2p' |sed -En 's/[^>]*>(.+)/\1/gp'
关于java - 如何从 shell 或 windows 命令行以内联方式执行 java jshell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46739870/
我正在编写一个 ruby 脚本来比较两组数字,这两组数字的误差应该在 5% 以内。有没有一种巧妙的方法可以在 ruby 中对此进行评估? 有点像 5.1.withinPercent(0.05)
我想在表单中使用文本输入来询问日期,但我不知道如何使用好这个模式属性。也许我应该使用一些小于 31 的正则表达式?我也不知道怎么做。 它是这样的: 我知道只使用选择或数字会更容易,但我必须以文本形
public static double squareRoot(double num) throws IllegalArgumentException { if (num =
在我的 Angular 2 元素中,我使用 Angular 2 Material 设计来显示进度我使用了这样的进度圈,实际上我将它用作超时并且我想限制为 60 秒,比如当 60 到达时整个进度应该是满
我知道必须有 100 种方法可以做到这一点 - 但有人可以推荐“最好/最简单”的方法来检查三个整数变量是否在彼此的一个点内。 $a = 1; $b = 2; $c = 1; 由于每个变量都在 1 点以
Java 中有没有一种方法可以使得如果 X 在 Y 的 3 以内,则它为 true(需要一个 if 语句)。我尝试过: import java.util.*; import java.
完全是菜鸟问题,但我正在上第一堂 Java 课,正在解决一组问题。我知道如何查看一个数字是否在特定范围内(下面发布),但我试图找出这是否适用于最近的数百个数字。 规则是 N 必须在最接近的 100 两
我有一个 android 布局,它有一个谷歌地图布局,底部覆盖有一个小的 LinearLayout。当用户选择 map 上的标记时,这个小布局就会变得可见。现在,我想知道选中的标记是否在选中时被小布局
我想检查列表值是否具有某种程度的“接近度”。有没有好的算法可以做到这一点?最 pythonic 方式的奖励积分。 有效 [1,7,8,9] [3,4,100,101,102,103,104,105]
我正在对 2 个数字执行 AssertEval,只要它们完全相同,它就会通过。我的问题是,无论哪种方式,这些数字都可以在 5 以内。目前,如果它们不匹配,脚本就会失败。 我对 javascript 很
我正在寻找具有以下功能的虚拟机: 编译代码占用空间小(不到 200K)。 没有外部依赖。 Unicode(或原始)字符串支持。 整洁的代码/组织良好。 C(99) 代码,不是 C++。 类 C/Jav
这是我目前所拥有的,但如果我超过前一个数字的正负 11,它就会中断。因此,如果前一个数字是 1,则下一个数字必须大于 16。此外,我试图只使用每个数字一次。 示例输出: [3,45, 1, 16, 3
我是一名优秀的程序员,十分优秀!