#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    22
    Rep Power
    0

    How do we change text color in Unix using bash shell


    How do we change text color in Unix using bash shell.
    Can any one help? I am having trouble to change the text color.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Location
    USA
    Posts
    61
    Rep Power
    11
    Well I'm not sure exactly what you are trying to do but here is a small example:

    Code:
    /* black bg, with red text */
    #define BR "\033[1;31m"
    /* back to normal text */
    #define NORMAL "\033[0m"
    
    printf(BR "red text, black background" NORMAL);
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    22
    Rep Power
    0

    doesnt work


    I try it and it doesn't work.

    For example when the user enter somthing wrong.
    then I would like to give an error message display in red to get their attention and make my point stand out.

    Can anyone help please
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    144
    Rep Power
    11

    The previous answer is correct


    Colors are controlled by escape sequences. Are you sure your terminal supports colors? Does ls --color=auto give you a file listing with colors?

IMN logo majestic logo threadwatch logo seochat tools logo