0

Trying to test functions on ShellScript, but I keep receiving the answer: "Command not found"

# Trying to create functions that receives arguments e have returns
# The function will receive two values and say hwo is bigger

bigger () {
if [$1 -gt $2]
then
   return $1
else
   return $2
fi
}

echo "Size does matter!!!!"
echo " "
printf "Enter the first number: - "
read data1
echo " "
printf "Enter the second number: - "
read data2
echo " "
printf "The bigger number is: - "
bigger $data1 $data2

The result I get is:

enter image description here

1 Answers1

0

You have a syntax error and bash tries to interpret [1 as a command. Add spaces to fix this

Change

if [$1 -gt $2]

to

if [ "$1" -gt "$2" ]
Tolis Gerodimos
  • 3,782
  • 2
  • 7
  • 14