Hello, I'm new to this forum, and I apologize in advance if I did something wrong here.
I am pretty stumped here as I am still getting the error message, "./comc1.sh: test: argument expected." after executing the script itself.
Here's the script file I modified:
Quote:
1 #!/bin/sh
2 # comc1.sh: Script that is called by different names
3 #
4 lastfile=`ls -t *.c 2>/dev/null | head -n 1`
5 [ -z $lastfile ] && { echo "No C program found" ; exit 1 ; }
6 echo "Test is good"
I tried executing line 4 without the backquote in the shell. I tested it when there is no .c file in the current directory. I also created a fake .c file, and got the expected result too.
I also tried executing line 5 by itself after creating the child bash shell process, so I don't get myself kicked out of the term. Got both conditions to execute without a problem when lastfile was null and non-null.
Am I missing something here? I'm no script expert yet, but if I am suppose to enclose something else to make this script run, then can someone please points that out? Thanks.