Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Can any one please help me understand this code snippet that I found in .profile file

echo -en "\e[32;44m $(hostname) \e[m";echo -e "\e[m"
share|improve this question
add comment

2 Answers 2

up vote 10 down vote accepted

This snippet is used to print out the hostname of the system with a blue background and a green font.

To color your shell, you use special color escape sequences.

\e[ starts the color scheme, 32; will set the foreground color to green, 44 will set the background color to blue and m will end it.

$(command) creates a new shell, executes command and returns the result (not the return value).

hostname returns the hostname of the current system.

\e[m will reset the coloring of the output.

From the echo manpage:

   -n     do not output the trailing newline
   -e     enable interpretation of backslash escapes

IMHO your snippet could be simplified to echo -e "\e[32;44m $(hostname) \e[m";

See the chapter 6.1 Colours of the BASH Prompt HOWTO for more details.

share|improve this answer
add comment

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.