Wildcards in dircolors definitions?

438 views Asked by At

I'm setting up a .dir_colors file, but I have a bit of an issue I can't seem to figure out.

I have PBS job scripts that I want colored, which work fine:

.job 01;35

But the output of these scripts generate two files each: output and error, which take the form:

.job.o354282 .job.e354282

Where the PBS job number is 354282. I'd really like to highlight both types, but the only way I can think of doing this is with wildcards like:

.job.o* 01;37
.job.e* 01;36

Which doesn't seem to work. I obviously can't hard code in every file extension possibility as I can't predict what my job numbers will be. Is there a way to use wildcards in a .dir_colors file, or some other way to solve this problem?

Thanks.

2

There are 2 answers

0
David Newcomb On BEST ANSWER

Your generated job files look like they follow a predefined format. Perhaps you can change their format to:

354282.job.o
354282.job.e

or whatever so that the extension remains the same as wildcards are not supported in LS_COLORS.

0
ceving On

It is not possible. The ls command does not accept a globbing pattern. You can test it by setting the LS_COLORS by hand:

$ export LS_COLORS='no=00:*.rpm=00;31:*.o*=00;31'

The above will render rpm files red and those wich end on '.o*'. They must have a '*' in the file name. Try it with:

$ touch nix.rpm job.o123 job.o\*
$ ls