my default profile is using ksh, I tried to write a simple scripts and I had issues, below is my scripts:
$ more if_num.ksh
USAGE="usage: if_num.ksh"
print -n "Enter two numbers: "
read x y
if ((x=y))
then
print "You entered the same number twice."
when I tried to executed the script below is the errors:
$ ./if_num.ksh
./if_num.ksh: line 3: print: command not found
thanks comments I did wrong here?
Thanks,
You assumed a suffix would suffice to tell the OS what interpreter to run.
The correct way is to have this as first line:
#! /bin/ksh
You are certainly using a Unix variant that uses bash as default shell and bash doesn't implement "print".
can someone please tell me what I did wrong here?
You can write:
echo $SHELL
to know what shell are you using.
'print' is a ksh sentence but it is not in bash, so probably our shell is bash.
Matthew,
As suggested above, your first line of script should have interpretter that needs to be used to evaluate shell script. It can be
Can you let me know output of below command?
echo $SHELL tells you which shell you're currently working in, as an interactive shell. It has no relationship to the first line in a script.
---------- Post updated at 05:52 AM ---------- Previous update was at 05:48 AM ----------
if ((x=y))
then
print "You entered the same number twice."
should be:
if ((x==y))
then
print "You entered the same number twice."
fi