Why variable $c in end of code not echo "smile" but only echo empty value?
I wont get variable $c after end of "if operator" but when operator finish job my value $c not return "smile" but only return "" (empty value)
#!/bin/bash
###
## sh example.sh
a="aaa"
b="bbb"
if [ "$a" != "$b" ]; then (
c="smile"
echo "echo inside if:"
echo $c # in this echo "smile"
) else (
c="yes"
) fi
echo "echo after fi:"
echo $c # echo "" # why this not echo "smile"
result:
[root@my-fttb ~]# sh /folder/example.sh
echo inside if:
smile
echo after fi:
[root@my-fttb ~]#