Answer the question
In order to leave comments, you need to log in
Bash Script is not working correctly, why?
The script is very simple, rewritten from a book for practice:
#!/bin/sh
#
#
#
echo "script4 - Linux Scripting Book"
if [ $# -ne 4 ] ; then
echo "Usage: script4 number1 number2 number3 number4"
echo " Please enter 4 numbers."
exit 255
fi
echo Parameters: $1 $2 $3 $4
echo Showing logical AND
if ; then # logical AND
echo Clause 1
else
echo Clause 2
fi
echo Showing logical OR
if ; then # logical OR
echo Clause 1
else
echo Clause 2
fi
echo "End of script4"
exit 0
Answer the question
In order to leave comments, you need to log in
the script is working
$ bash --version
GNU bash, версия 5.1.4(1)-release (x86_64-pc-linux-gnu)
...
$ ./untitled.sh 1 1 1 1
script4 - Linux Scripting Book
Parameters: 1 1 1 1
Showing logical AND
Clause 1
Showing logical OR
Clause 1
End of script4
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question