Sponsored Content
Full Discussion: Changing text colour in bash
Top Forums Shell Programming and Scripting Changing text colour in bash Post 302369482 by cfajohnson on Sunday 8th of November 2009 08:37:53 PM
Old 11-08-2009
Quote:
Originally Posted by TonyLawrence
Use "tput"

tput setaf 2

That doesn't work on at least one of the systems I use. There are two different versions of tput. One uses termcap, the other terminfo. They are not compatible.

On the other hand, the ISO 6429 standard (also known as ECMA-48, and formerly known as ANSI X3.64), is ubiquitous, and terminals that do not support it are few and far between.

Code:
green=$(printf "\033[32m")
normal=$(printf "\033[m")

Quote:

I honestly don't like colors for scripts.

Generally, I agree with you, but there are times when it is useful.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

HOw to change the text colour through shell script?

Hi all, I have written one script. If i run the script, particular text in that script needs to be displayed in color.how this could be done?any commands r there to change the colour of the text while running the script? Ur help is appreciated !!! Thanx in Advance, Sona. (7 Replies)
Discussion started by: Sona
7 Replies

2. UNIX for Dummies Questions & Answers

Need help with changing bash to perl

Hi guys, I am converting a bash script to perl. I need lots of help and pointers on how to make the script work. Any help would be greatly appreciated. Here is what I have: #!/usr/bin/perl #Decrypt Files $dir = "/usr/bin/gpg; opendir(PGP_DIR, $dir) || die "can't opendir $dir: $!";... (3 Replies)
Discussion started by: freak
3 Replies

3. Shell Programming and Scripting

bash changing file name

I want to run some unix commands on one file..let say if i change the name and that name of file is present already. I dnt want to change that presnt file but instead of that make another one with different name eg.. usa.txt if it is there make usa.txt.1 something like that Also one more... (5 Replies)
Discussion started by: Learnerabc
5 Replies

4. Shell Programming and Scripting

changing cron using bash script

How can I change the cron entries only for ABC and XYZ from dosomething_1.0.sh to nowchanged_2.0 using a bash script ? Any help will be appreciated. # # ABC 00,05,10,15,20,25,30,35,40,45,50,55 * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1 # # ## # DEF... (4 Replies)
Discussion started by: jville
4 Replies

5. Shell Programming and Scripting

Bash - changing a color of a substring

Hello! I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Discussion started by: xqwzts
3 Replies

6. UNIX for Dummies Questions & Answers

Changing text in multiple files, but with different text for each file

Hello, I have a situation where I want to change a line of text in multiple files, but the problem is that I want to change the text to something unique for each file. For example, let's say I have five files named bob.txt, joe.txt, john.txt, tom.txt, and zach.txt. Each of these files has a... (5 Replies)
Discussion started by: Scatterbrain26
5 Replies

7. HP-UX

Changing default shell to bash

According to multiple sources you should not change the default shell to bash for the root user because it will make the system unbootable. Is there a safe way to launch bash for root when logging in? Perhaps I can edit /etc/profile or add it to a startup script somewhere? (2 Replies)
Discussion started by: bstring
2 Replies

8. Shell Programming and Scripting

Changing IFS in bash function

I have a function in bash that takes arguments. does IFS work in a function or does it apply only to the main script? (1 Reply)
Discussion started by: kristinu
1 Replies

9. Shell Programming and Scripting

awk and HTML with conditional text colour

Hello All, I am using awk with html options to format and send output to another file. Below command works fine, no issues. awk 'BEGIN{print "<table border="1" width="1000" >"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END {print "</table>"}' ${TMPLOGFILE1} >>... (0 Replies)
Discussion started by: jvmani_1
0 Replies

10. Shell Programming and Scripting

Changing from bash to ksh

Hello, I want to run a script written in ksh but my default shell is bash as root e.g in the script it has #!/bin/ksh i have gone into /etc/passwd to change it from :/bin/bash to /bin/ksh but still giving me an error when running scripts such as ./installer -bash: ./installer: /bin/ksh:... (3 Replies)
Discussion started by: DOkuwa
3 Replies
Graph::colour(3)					User Contributed Perl Documentation					  Graph::colour(3)

NAME
GD::Graph::colour - Colour manipulation routines for use with GD::Graph SYNOPSIS
use GD::Graph::colour qw(:colours :lists :files :convert); DESCRIPTION
The GD::Graph::colour package provides a few routines to work with colours. The functionality of this package is mainly defined by what is needed, now and historically, by the GD::Graph modules. FUNCTIONS
colour_list( number of colours ) Returns a list of number of colours colour names known to the package. Exported with the :lists tag. sorted_colour_list( number of colours ) Returns a list of number of colours colour names known to the package, sorted by luminance or hue. NB. Right now it always sorts by luminance. Will add an option in a later stage to decide sorting method at run time. Exported with the :lists tag. _rgb( colour name ) Returns a list of the RGB values of colour name. if the colour name is a string of the form that is acceptable to the hex2rgb sub, then the colour will be added to the list dynamically. Exported with the :colours tag. _hue( R,G,B ) Returns the hue of the colour with the specified RGB values. Exported with the :colours tag. _luminance( R,G,B ) Returns the luminance of the colour with the specified RGB values. Exported with the :colours tag. add_colour(colourname => [$r, $g, $b]) or add_colour('#7fe310') Self-explanatory. Exported with the :colours tag. rgb2hex($red, $green, $blue) hex2rgb('#7fe310') These functions translate a list of RGB values into a hexadecimal string, as is commonly used in HTML and the Image::Magick API, and vice versa. Exported with the :convert tag. read_rgb( file name ) Reads in colours from a rgb file as used by the X11 system. Doing something like: use GD::Graph::bars; use GD::Graph::colour; GD::Graph::colour::read_rgb("rgb.txt") or die "cannot read colours"; Will allow you to use any colours defined in rgb.txt in your graph. Exported with the :files tag. PREDEFINED COLOUR NAMES
white, lgray, gray, dgray, black, lblue, blue, dblue, gold, lyellow, yellow, dyellow, lgreen, green, dgreen, lred, red, dred, lpurple, purple, dpurple, lorange, orange, pink, dpink, marine, cyan, lbrown, dbrown. AUTHOR
Martien Verbruggen <mgjv@tradingpost.com.au> Copyright GIFgraph: Copyright (c) 1995-1999 Martien Verbruggen. Chart::PNGgraph: Copyright (c) 1999 Steve Bonds. GD::Graph: Copyright (c) 1999 Martien Verbruggen. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
GD::Graph, GD::Graph::FAQ perl v5.12.1 2005-12-14 Graph::colour(3)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy