return statement error:urn: can only `return' from a function or sourced script in shell script myscript.sh
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Incorrect Usage : Arguments mismatch."
return 2
fi
mv $1 $2
return 0
When i try to run
sh myscript.sh
Incorrect Usage : Arguments mismatch.
myscript.sh.sh: line 5: return: can only `return' from a function or sourced script
how to fix that error ?
I guess you mean
exit 2
and
exit 0
Also, have a second look at the syntax of test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With