Sponsored Content
Top Forums Shell Programming and Scripting setting width in echo statement Post 302193030 by drl on Thursday 8th of May 2008 10:14:36 AM
Old 05-08-2008
Hi.

This worked in a Linux Konsole and an xterm to set the color:
Code:
#!/usr/bin/perl

# @(#) p0       Demonstrate color in perl.

# use warnings;
# use strict;

$rgb_restore = "\e[00m";
$rgb_black   = "\e[00;30m";
$rgb_red     = "\e[01;31m";
$rgb_green   = "\e[01;32m";

print "\nWith print:\n";
print " The word $rgb_red red $rgb_restore is red.\n";
print " The word $rgb_green green $rgb_restore is green.\n";

print "\nWith printf:\n";
printf(" The word $rgb_red red $rgb_restore is red.\n");
printf(" The word $rgb_green green $rgb_restore is green.\n");

print "\n";
print "$rgb_restore (Restoring)\n";
print "$rgb_black (Black)\n";

exit(0);

As you probably know, the color codes go up through "01;37m" for white ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo statement

Does anyone know the correct syntax for computing arithmetic expressions inside the echo statement? Let me know, thanks (3 Replies)
Discussion started by: circleW
3 Replies

2. Shell Programming and Scripting

Perl equivalent of ksh if / echo statement

Is there an equivalent perl statement for the following ksh statement ? example if then ... else ... fi (2 Replies)
Discussion started by: gefa
2 Replies

3. Shell Programming and Scripting

Insert TAB in echo statement

Hi, Can some1 help me to output a tab in an echo statement. I have tried echo "RNC: \t NODEB" but dont get the correct output. I am a beginnger to unix, so pls hold back the laughs....if u can (5 Replies)
Discussion started by: sunils27
5 Replies

4. Shell Programming and Scripting

echo statement issue

Hi All, I am pasting my code below if # e means file exists then echo OFR_Configlist exists >> OFR_Backup_Configfiles.log else echo OFR_Configlist Not exists >> OFR_Backup_Configfiles.log exit fi How can i show the echo message in console also at the same time? I dont want to write... (3 Replies)
Discussion started by: subin_bala
3 Replies

5. Shell Programming and Scripting

Output of both the echo statement in one line

I have script like echo -n FINISHED FEXP: ${TABLE2EXP} echo $STATUS I want the output of both the echo statement in one line How can i do this (3 Replies)
Discussion started by: scorp_rahul23
3 Replies

6. Shell Programming and Scripting

Setting Echo Off

Hi How to set the ECHO off in shell scripts so that the default output will be hidden. (2 Replies)
Discussion started by: Joseph Antoine
2 Replies

7. Shell Programming and Scripting

how to read a file to an echo statement

I was searching for an option where i can echo some strings together with the contents of a file. Eg. I was to echo the below string to a file "alter application PMS_ add variable CurrYear Y2009;" >> ${ESS_MAXL_DIR}/PMS_SUB.txt The value 2009 is coming from a file called date.txt without the... (3 Replies)
Discussion started by: Celvin VK
3 Replies

8. Shell Programming and Scripting

Wierd behaviour setting stty echo

Hi all, Encountered a wierd behaviour which I am unable to understand. I have a function doing the follow: function RETRIEVE_PASSWORD { if (( $DC_ACCOUNT )) then clear printf "\nEnter Password for ${ConfiguredUser}" printf... (1 Reply)
Discussion started by: srage
1 Replies

9. Shell Programming and Scripting

concatinate a string with output of echo statement

I need to concatinate a string (mapping-expression) with the output of below statement EXPRESS="cat //normalization-binding//tag-normalization/tag-name" echo $EXPRESS | xmllint --shell QA_Oct12_DIR.cfb | grep -v "/ >" >> "/home/testBinding.txt" above statement write value="$6061" into... (1 Reply)
Discussion started by: bkc
1 Replies

10. Shell Programming and Scripting

If echo statement return false

I have this code that sometimes return a false value and the code inside the if statement gets executed and error out. Any idea why? thanks. So I set a debug and see what the value for $ScriptElapsedTime Here is the value I got ScriptElapsedTime='03:20'. Base on this value the if... (10 Replies)
Discussion started by: nugent
10 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 06:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy