C code - ls system command not showing bash colors
Posted
by
m0atz
on Ask Ubuntu
See other posts from Ask Ubuntu
or by m0atz
Published on 2014-06-01T09:38:36Z
Indexed on
2014/06/01
9:39 UTC
Read the original article
Hit count: 322
command-line
|bash
I've just been fooling around with some code in C, an example of a really basic program is as follows which just, obviously, lists the directories using the ls system command.
#include <stdio.h>
int main (void) {
system("ls -l -d */");
printf("I've just listed the directories :-)\n");
return 0;
}
This runs fine, but it shows the ls output in monochrome, whereas Bash would output the list using colors for the directories (or files if I included files). How can I make my C code use the bash colors? Thanks
© Ask Ubuntu or respective owner