Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] sed and ANSI sequences



I suspect echo protects youu fromm escapes unless specified with -e \e. 

The octal is better with sed/perl filter. 

May need separate parallel macros for generated errors via echo -e and filtered via sed (or perl, which has ansi terminal modules Term::ANSIColor in core lib since Perl 5.6 ). 

------Original Message------

From: Derek Martin
To: John Abreau
Cc: discuss at blu.org
ReplyTo: discuss at blu.org
Subject: Re: [Discuss] sed and ANSI sequences
Sent: Oct 17, 2011 12:54

On Mon, Oct 17, 2011 at 01:05:51AM -0400, John Abreau wrote:
> Rather than go to that extra trouble, why not just use '\033'
> (or '\\033'), which sed ill recognize correctly?

Because it doesn't work, at least on my system (though, I confess I
don't quite understand the results, only the second one makes sense to
me):

$ echo "hello my bold friend" |sed 's/bold/\033[1mbold\033[0m/g'
hello my bold33[1mboldbold33[0m friend
$ echo "hello my bold friend" |sed 's/bold/\\033[1mbold\\033[0m/g'
hello my \033[1mbold\033[0m friend

Or with double quotes:

$ echo "hello my bold friend" |sed "s/bold/\\033[1mbold\\033[0m/g"
hello my bold33[1mboldbold33[0m friend
$ echo "hello my bold friend" |sed "s/bold/\033[1mbold\033[0m/g"
hello my bold33[1mboldbold33[0m friend

Odd.

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.



Bill, typing with thumbs



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org