1

This code tries to display a echo instructions in yellow and prints back the next echo with the user input but it is failing.

#!/bin/bash
YELLOW="\033[33m";
echo -e '${YELLOW}enter app name'
read name

echo -e '${YELLOW}rebuild $name after code changes'

gives

${YELLOW}rebuild $name after code changes  

instead of what the user input in yellow. Any idea how to fix it?

0

1 Answer 1

6

Use soft (double) quotes, not hard (single) quotes, otherwise variables will not be expanded:

#!/bin/bash
YELLOW="\033[33m";
echo -e "${YELLOW}enter app name"
read name
echo -e "${YELLOW}rebuild $name after code changes"
Sign up to request clarification or add additional context in comments.

2 Comments

One problem I did not expect is that the colour affects all feature outputs, How can I make just the echo output yellow but not any thing else?
You would just need to add another control code at the end of the line to return to whatever your default colour is. However that is beyond the scope of this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.