On Tue, Mar 13, 2007 at 05:00:18PM +0100, Sylvester Lykkehus wrote:
> Randall R Schulz wrote:
> >On Tuesday 13 March 2007 02:42, Sylvester Lykkehus wrote:
> >  
> >>echo -e '\E32mTest'
> >>Prints the word Test in green.
> >>    
> >
> >Here you're invoking the shell's built-in echo command, which interprets 
> >\E:
> >  
> >>While
> >>echo Test > test.txt
> >>cat test.txt | xargs -i echo -e '\E32m{}'
> >>prints \E32mTest
> >>    
> >
> >In this case, you're running /bin/echo, which does not support quite the 
> >same set of escape characters:
> >
> ><snip>
> >  
> >The above information should be enough to alliow you to correct the 
> >problem. That and the fact that ESC (escape) is octal 33 (this 
> >information is available via "man ascii").
> >
> >
> >Randall Schulz
> >  
> Aha!
> 
> So that means it should be e.g.
> /bin/echo -e '\033[01;32mTest'

Better use

  green="$(tput setaf 2 2>/dev/null)"
  norm="$(tput sgr0 2>/dev/null)"
  echo "${green}Test${norm}"

simply to get it green even if the terminal
does not know about ANSI sequencies or use
other sequencies.


     Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to