no output from unix shell script

我的未来我决定 提交于 2021-02-05 12:26:05

问题


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.

What am I missing?


回答1:


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).

This is why you should avoid calling your test programs test. Try try instead.



来源:https://stackoverflow.com/questions/38667256/no-output-from-unix-shell-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!