Hi!
I am using bash 2.05b. I have a script that uses =~ operator but it is not recognized in this version. It works fine on bash 3.2.x though. Can someone please let me know how to get around this?
Here is the code.
function (){
.......
local SEC="^\[$SECTION\]"
local KEYVALUE="^$KEY=(.*)"
while read line; do
if [ $section = 0 ]; then
if [[ $line =~ $SEC ]]; then
section=1
continue
fi
else
if [[ $line =~ $KEYVALUE ]]; then
echo ${BASH_REMATCH[1]}
return 0
fi
fi
done <"$FILE"
return 1
}
Thanks in advance.
I am using bash 2.05b. I have a script that uses =~ operator but it is not recognized in this version. It works fine on bash 3.2.x though. Can someone please let me know how to get around this?
Here is the code.
function (){
.......
local SEC="^\[$SECTION\]"
local KEYVALUE="^$KEY=(.*)"
while read line; do
if [ $section = 0 ]; then
if [[ $line =~ $SEC ]]; then
section=1
continue
fi
else
if [[ $line =~ $KEYVALUE ]]; then
echo ${BASH_REMATCH[1]}
return 0
fi
fi
done <"$FILE"
return 1
}
Thanks in advance.