Is there a way to change the color of only one of the listed directories in the ls command? I have researched the LS_COLORS variable, but this doesn't solve the issue because you cannot list specific files or directories in the LS_COLORS variable.

I have been producing a bash script to accomplish this, but so far it's proven extremely complicated. There must be an easier way.


2 Answers 2


As I understands it, you can only specify files that ends with a specific pattern, for example *.jpg=01;31 to make jpg-files red. Then of course you can always trick it with something like this *IMG_20150808_202948.jpg=01;31 :)


Agreeing with @nsg that you cannot do this, it seems that the documentation is lacking. So you can read the source-code for ls, in print_color_indicator, in particular the place where it checks file-suffix, commenting

/* Check the file's suffix only if still classified as C_FILE.  */

So, no: you cannot fool it by making a directory-name ending with ".jpg". You can only apply the suffixes to filenames (and see the code) the suffix need not begin with a ".".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .