no output from unix shell script

前端 未结 1 1039
北恋
北恋 2021-01-29 06:35

I have the following shell script (named test):

#!/bin/sh
echo \"junk\"
filename=\"junk\"
echo $filename
filename=`ls -t|head -n1`
echo $filename


        
相关标签:
1条回答
  • 2021-01-29 07:28

    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.

    0 讨论(0)
提交回复
热议问题