Hello. I'm trying to get a not-so complex if-else to work on my FreeBSD box but I'm getting an error with the second part of the condition. Basically, this is what I'm trying to do:
This is the actual code I'm using:
It gives me an error about "[[". I tried adding/removing brackets to no avail. I' I've also searched the net for similar examples but the ones I've seen are very simplistic (i.e. if var=value then do this). I could separate the conditions into two "ifs" but I think it can be done in one and I want to know "advance" if-else in Bourne as well.
Any help would be greatly appreciated.
Thanks
Code:
if not file-exists or (file-exists and string exists in file) then
do this
else
do something else
This is the actual code I'm using:
Code:
if [ ! -f /boot/loader.conf ] || [[ -f /boot/loader.conf ] && ! grep -Fqx "zfs_l
oad" /boot/loader.conf ]; then
echo "found"
else
echo "not found"
fi
It gives me an error about "[[". I tried adding/removing brackets to no avail. I' I've also searched the net for similar examples but the ones I've seen are very simplistic (i.e. if var=value then do this). I could separate the conditions into two "ifs" but I think it can be done in one and I want to know "advance" if-else in Bourne as well.
Any help would be greatly appreciated.
Thanks