if [ $data == $dis ]
this line is not giving expected results in the script
Tried on terminal, it works fine. "true" is expected from the script and then wanna delete that line from the file
root@M5-L-G01FQY9:/mnt/c/Users/Vinita.a.wadhwani/Downloads/Rough# d="<disabled></disabled>"
root@M5-L-G01FQY9:/mnt/c/Users/Vinita.a.wadhwani/Downloads/Rough# c="<disabled></disabled>"
root@M5-L-G01FQY9:/mnt/c/Users/Vinita.a.wadhwani/Downloads/Rough# if [ $d == $c ]
> then
> echo "true"
> fi
true
Code is as follows:
dirmon=$1
action=$2
node=$(grep -l $dirmon *)
line=$(grep -n -m 1 $dirmon $node | sed 's/\([0-9]*\).*/\1/')
echo 'Performing' $action 'action on dirmon-'$dirmon 'which is present in node-'$node
no=$(($line+20))
data=$(sed -n "${no}p" $node) #gives results as <disabled></disabled>
echo $data
dis="<disabled></disabled>"
echo $dis
if [ $data == $dis ]
then
echo 'true'
fi
#echo 'false'
expected results:
root@M5-L-G01FQY9:/mnt/c/Users/Vinita/Downloads/Rough# ./On* YELLOW start
Performing start action on dirmon-YELLOW which is present in node-NODE.txt
<disabled></disabled>
<disabled></disabled>
true
Actual results
root@M5-L-G01FQY9:/mnt/c/Users/Vinita/Downloads/Rough# ./On* YELLOW start
Performing start action on dirmon-YELLOW which is present in node-NODE.txt
<disabled></disabled>
<disabled></disabled>