The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
echo statement issue subin_bala Shell Programming and Scripting 3 04-23-2008 11:13 PM
If statement - How to write a null statement april Shell Programming and Scripting 3 04-16-2008 10:14 AM
Insert TAB in echo statement sunils27 Shell Programming and Scripting 5 08-26-2005 12:36 AM
Perl equivalent of ksh if / echo statement gefa Shell Programming and Scripting 2 02-17-2005 09:07 AM
echo statement circleW Shell Programming and Scripting 3 10-03-2004 08:06 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-08-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 18
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.
Reply With Quote
Forum Sponsor
  #2  
Old 05-08-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,198
Use printf instead of echo. Search on the net for printf examples.

Regards
Reply With Quote
  #3  
Old 05-08-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 18
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..
Reply With Quote
  #4  
Old 05-08-2008
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 546
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
Reply With Quote
  #5  
Old 05-12-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 18
Thanks drl...

I got it []
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0