On Linux if-else code is:
if [[ condition ]]
then
echo ""
else
echo ""
fi
How does the above code changes when scripting in MacOS?
Bash is basically the same on any platform. Your if-else code will be exactly the same on Linux, MacOS or even Windows.
The main differences you could find are:
bash
are basically the same on any platform. It's well known that the version of bash
that ships with macOS is quite a bit older than what you can typically expect from most Linux distributions.
It does not. On both Linux and Darwin, the statement you have specified returns a continuation prompt (i.e. '> '):
$: if [[ 1 ]] then echo "true" else echo "false" fi
This however, works exactly the same on Linux and MacOS
$ if [ 1 ]; then echo "it is true"; else echo "it is false"; fi it is true
bash
; most Linux distributions ship a newer version. What is the exact code you are running, and how does its result differ from what you are expecting?