Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

For some reason the color escape characters in my /etc/issue file are not working. They're being displayed as text:

Here is the content of the file:

^[[1;31mUbuntu^[[0m

And it outputs the exact same thing at the login prompt:

^[[1;31mUbuntu^[[0m

The escapes are not properly recognized, so how can I solve that?

share|improve this question
    
Err... if this is a bash script using echo, you have to use echo -e... For more see man echo? What are you trying to do? –  Wilf Dec 9 '13 at 21:33
    
Does this help? –  Wilf Dec 9 '13 at 21:35

1 Answer 1

up vote 3 down vote accepted

The escape codes needs to be interpreted correctly and not literally, before writing the string to file:

# echo -e '\e[1;31mUbuntu\e[0m' > /etc/issue
share|improve this answer
    
How weird, sort of get it now... –  Wilf Dec 9 '13 at 21:37
    
@wilf @ErikCalvalho FYI, using the # and $ before a command is a well established norm to express "run the following command as root" or "run the following command as normal user", respectively, so please don't make any more edit suggestions to that particular issue. The command here needs to have root privileges, so it's important to point out. –  Herman Torjussen Dec 10 '13 at 8:25
    
Yes, but it won't work with the # in the code block - sorry, but can't you just put RUN THIS AS ROOT or sudo.... ? –  Wilf Dec 10 '13 at 11:19
    
@wilf Everyone knows that. The intent is clear - no need for "run the following as root" or "you need to have administrative rights". You'll see this used everywhere in command-line examples on the web and at SE sites. The # $ prefixes are useful to distinguish between commands and output. –  Herman Torjussen Dec 10 '13 at 12:58
1  
I thought it was pretty self explanatory. Didn't even really think think about it. Just read the line in my head as root. It's kinda like that first instance when you start reading a new language as itself, not a translation. –  Atomiklan Dec 10 '13 at 18:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.