Why my bash script prints the same text line twice

Posted on

Problem :

I have a script:


# Font colors
echo -e "${STR_BLUE}Building openssl for linux-x86 $VERSION_FILE${STR_RESET}"


+ echo -e 'e[1me[34mBuilding openssl for linux-x86e[0m'
Building openssl for linux-x86

The second line shows the correct bold font with blue color. But how can I remove the first line?

Solution :

It seems you are executing your script with debug options. See the Debugging Bash scripts documentation. But I don’t know how you started it.

Try putting set +x at the beginning of your script to disable debugging.

Hypothesis: there is set -x in the script just before echo.

Print a trace of simple commands […] after they are expanded and before they are executed.


Solution: remove set -x.

Leave a Reply

Your email address will not be published. Required fields are marked *