I try to compare in a Script two different version numbers of Drupal via
The result should be printed out in a if-else.
I made a minimal example:
# put paths in vars WEBSITE_ROOT_LIVE=/PATH/TO/LIVE WEBSITE_ROOT_TEST=/PATH/TO/DEV # get the drupal version line from drupal status output cd $WEBSITE_ROOT_TEST test=$(drush status | grep "Drupal version") cd $WEBSITE_ROOT_LIVE live=$(drush status | grep "Drupal version") # count chars in output wc -c <<< $live wc -c <<< $test # print variables echo $live echo $test # compare if [ "$test" != "$live" ] then echo "not equal" else echo "equal" fi
Strangely this is the output:
84 88 Drupal version : 9.5.0 Drupal version : 9.5.0 not equal
The difference in characters is the explanation, but why are they different? On one side
the string has not so much chars, on the other side they are different length.
Why is that so, and how can i fix this?
I suspect the substitution within the shells