setting width in echo statement

Hello All,

I need to set the width or number of columns for my dynamic output in the echo statement.

statement is like:

echo " <output> [PASS]"

here the <output> is dyamice and can be of any number of characters, the " [PASS]" should always start in same column everytime it is exected.

Use printf instead of echo. Search on the net for printf examples.

Regards

I am using this echo statement in perl ... i want my output in color... i think i cant make the output on screen in color with " printf" statement.. please tell me if it is possible for printf to give colored output..

Hi.

This worked in a Linux Konsole and an xterm to set the color:

#!/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

Thanks drl...

I got it [:)]