Sponsored Content
Full Discussion: Using color in scripts
Operating Systems Linux Ubuntu Using color in scripts Post 303033721 by drew77 on Wednesday 10th of April 2019 03:15:08 PM
Old 04-10-2019
Using color in scripts

This is supposed to colorize.

But it outputs this

Code:
3[0;32mFile exists.3[0m

Code:
GREEN='3[0;32m'
RED='3[0;31m'
WHITE='3[0;37m'
RESET='3[0m'
FILE="/usr/share/sounds/My_Sounds/Short_doorbell.wav"

if [ -f "$FILE" ];
then
     echo -e "${GREEN}File exists.${RESET}"
else
     echo -e "${RED}File does NOT exist.${RESET}"
     
fi

 

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
All times are GMT -4. The time now is 10:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy