hdfs 测试结果仅在键入 $?
hdfs test result only displayed after typing $?
为什么我 运行 命令:
hdfs dfs -test -d /user/me/dirs
我必须输入 $?
才能得到结果:
sh: 0: command not found
有没有办法我可以只得到结果(0 或 1)本身和其他文本的 none?
在 bash 时非常糟糕,所以我可能会遗漏一些东西
在bash中,$?
给出了上一个命令的退出代码。简单地键入 $?
将导致您的 shell 尝试将 return 代码作为命令执行(这通常不是您想要的)。您可以改为使用 echo $?
打印值,或使用 retcode=$?
.
将其保存在变量中
退出代码通常不会打印到您的shell。您可能看不到任何其他输出的原因是因为 hdfs
命令可能没有在您的屏幕上打印任何文本(通过 stdout
或 stderr
)。
我怀疑您最好的选择可能是 hdfs dfs -test -d /user/me/dirs; echo $?
,或者使用变量的一些变体。
为什么我 运行 命令:
hdfs dfs -test -d /user/me/dirs
我必须输入 $?
才能得到结果:
sh: 0: command not found
有没有办法我可以只得到结果(0 或 1)本身和其他文本的 none?
在 bash 时非常糟糕,所以我可能会遗漏一些东西
在bash中,$?
给出了上一个命令的退出代码。简单地键入 $?
将导致您的 shell 尝试将 return 代码作为命令执行(这通常不是您想要的)。您可以改为使用 echo $?
打印值,或使用 retcode=$?
.
退出代码通常不会打印到您的shell。您可能看不到任何其他输出的原因是因为 hdfs
命令可能没有在您的屏幕上打印任何文本(通过 stdout
或 stderr
)。
我怀疑您最好的选择可能是 hdfs dfs -test -d /user/me/dirs; echo $?
,或者使用变量的一些变体。