0

I am trying to compare two numbers in bash, but I want it to be in a function and then return with Passed or Failed

So far I have this

myfunc(){
if ["$val1" -eq "$val2"]; then 
   echo "Passed"
else 
   echo "Failed"
}

echo "$myfunc"

The desired output would be if i have val1 = 2 and val2 = 2, they are equal thus it will return

Passed
Samathingamajig
  • 11,839
  • 3
  • 12
  • 34
Gabi
  • 9
  • 4
  • 1
    Please add a suitable shebang (`#!/bin/bash`) and then paste your script at http://www.shellcheck.net/ and try to implement the recommendations made there. – Cyrus Oct 12 '22 at 15:20

0 Answers0