I have the following shell script (named test
):
#!/bin/sh
echo \"junk\"
filename=\"junk\"
echo $filename
filename=`ls -t|head -n1`
echo $filename
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.