Unix Shell脚本无输出 [英] no output from unix shell script
本文介绍了Unix Shell脚本无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下外壳程序脚本(名为 test
):
I have the following shell script (named test
):
#!/bin/sh
echo "junk"
filename="junk"
echo $filename
filename=`ls -t|head -n1`
echo $filename
当我运行此脚本时,没有输出到终端.我正在使用红色的帽子/腻子.
when I run this script there is no output to the terminal. I am using red hat / putty.
我想念什么?
推荐答案
您不小心运行了名为 test
的系统命令,该命令不产生任何输出.您需要使用 ./test
代替在当前目录中查找脚本,而 test
将使用内置的shell命令(即使没有,它会找到/usr/bin/test
来代替).
You're accidentally running the system command called test
, which produces no output. You need to use ./test
instead to find the script in the current directory, whereas test
will use the built-in shell command (and even if it didn't, it would find /usr/bin/test
instead).
这就是为什么您应该避免调用测试程序 test
的原因.试试 try
.
This is why you should avoid calling your test programs test
. Try try
instead.
这篇关于Unix Shell脚本无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文