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.

Is it possible to only reset the background color or text color back to default (not both!)

Example:

echo -e "\033[32;41mFoo bar\033[30m baz" # Doesn't reset background color
echo -e "\033[32;41mFoo bar\033[0m baz" # Resets the background color and text color

Is there anyway to do this?

I know I can assign the background color in the second statement, but the color will be unknown. (echo -e "\033[32;41mFoo bar\033[0m baz")

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

The colors 39 and 49 means the default color, for the foreground and the background respectively. \e[0m is equivalent to \e[22;24;25;27;28;39;49m (not bold, not underlined, not blinking, not inverse, not hidden, default foreground, default background).

You can find the terminal control sequences in the xterm documentation (most terminals follow xterm's lead nowadays).

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.