Using this script to confirm a macOS Config Profile is installed
#!/bin/bash
NAME="ApplicationName - Config Profile"
profiles=$(profiles -C -v | awk -F: '/attribute: name/{print $NF}' | grep "$NAME")
if [ "$profiles" == " $NAME" ]; then
echo "Profile exists"
else
echo "Profile does not exist"
fi
If I don't have the leading space in the conditional (the space before $NAME
) the conditional is wrong.
"$profiles" == "$NAME"
This returns "Profile does not exist"
"$profiles" == " $NAME"
This returns "Profile exists"
I can even echo $NAME
and $profiles
, they echo exactly the same, but the if conditional is different depending on that space. Why is this?