Sponsored Content
Full Discussion: Using color in scripts
Operating Systems Linux Ubuntu Using color in scripts Post 303033728 by drew77 on Wednesday 10th of April 2019 05:53:25 PM
Old 04-10-2019
I am using mate terminal.

I found another way which is easier to use and tput is part of the ncurses package and is supplied with most Linux distributions.

Code:
FILE="/usr/share/sounds/My_Sounds/Short_doorbell.wav"

if [ -f "$FILE" ];
then
     tput setaf 2; echo "File $FILE does exist."
else
     tput setaf 1; echo "File $FILE does NOT exist."
     
fi
tput sgr0    # Reset text format to the terminal's default


#Num  Colour    #define         R G B

#0    black     COLOR_BLACK     0,0,0
#1    red       COLOR_RED       1,0,0
#2    green     COLOR_GREEN     0,1,0
#3    yellow    COLOR_YELLOW    1,1,0
#4    blue      COLOR_BLUE      0,0,1
#5    magenta   COLOR_MAGENTA   1,0,1
#6    cyan      COLOR_CYAN      0,1,1
#7    white     COLOR_WHITE     1,1,1

These 3 Users Gave Thanks to drew77 For This Post:
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

2. UNIX for Beginners Questions & Answers

Text color in Linux scripts via putty

hi Folks, Can anyone help with changing the color of the words in a linux shell script? I get how to change default background etc in putty, but for some reason the text in the script has different colors for different parts of the cript. Is there a way to have one color in a linux shell... (5 Replies)
Discussion started by: jonnyd
5 Replies
pods::SDL::Color(3pm)					User Contributed Perl Documentation				     pods::SDL::Color(3pm)

NAME
SDL::Color - Format independent color description CATEGORY Core, Video, Structure SYNOPSIS
my $black = SDL::Color->new(0, 0, 0); my $color = SDL::Color->new(255, 0, 0); my $r = $color->r; # 255 my $g = $color->g; # 0 my $b = $color->b; # 0 $color->g(255); $color->b(255); # $color is now white DESCRIPTION
"SDL_Color" describes a color in a format independent way. METHODS
new my $color = SDL::Color->new(255, 0, 0); The constructor creates a new color with the specified red, green and blue values. r my $r = $color->r; $color->r(128); If passed a value, this method sets the red component of the color; if not, it returns the red component of the color. g my $g = $color->g; $color->g(128); If passed a value, this method sets the green component of the color; if not, it returns the green component of the color. b my $b = $color->b; $color->b(128); If passed a value, this method sets the blue component of the color; if not, it returns the blue component of the color. SEE ALSO
SDL::Surface AUTHORS
See "AUTHORS" in SDL. perl v5.14.2 2012-05-28 pods::SDL::Color(3pm)
All times are GMT -4. The time now is 03:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy