我想在Java中调用stat
,使用:
Runtime.getRuntime().exec("stat /*")
但总是得到退出代码 -1 和:
stat: cannot stat `/*': No such file or directory
在bash中运行stat/*
就可以了,这也可以:
Runtime.getRuntime().exec("stat /")
Java 中的 stat/*
是否与 bash 中的行为不同?
最佳答案
stat/*
在命令行中工作,因为 shell 解释 *
。
您应该尝试通过 bash 运行,例如 bash -c stat/*
关于java - stat 返回 `No such file or directory` ,在 java exec 下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61968981/