Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know, I can specify custom time format for ls like this

ls -lAF --time-style="+ %Y-%b-%d  %H:%M:%S" --color=always

but I would like to "smuggle in" colors inside the time format. For example, I would like to have the year 2014 in red color. How would I do that?

I have tried putting the color code \033[0;31m in front of the %Y, but the code does not get interpreted as color but as gibberish.

share|improve this question
up vote 11 down vote accepted

Enter the ESC character literally. This is usually done by entering Ctrl+V and then the requested key, in this case Esc.

Or in ksh93, zsh or bash, use the $'...' quotes where echo-like escape sequences are expanded:

ls -lAF --time-style=$'+ \e[31m%Y\e[m-%b-%d  %H:%M:%S' --color=always
share|improve this answer

Your Answer


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.