Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Question about backquotes and linux echo

Reply
Thread Tools

Question about backquotes and linux echo

 
 
Hartin, Brian
Guest
Posts: n/a
 
      04-09-2008
Hi all,

I can't figure out why the following works from the command line but not
from the backquotes:

echo -e "a\nb\naa" | grep a

This should produce:

a
aa


However, when I execute:

puts `echo -e "a\\nb\\naa" | grep a`

I get:

-e "a\nb\naa"

Of course, this is a trivial example, but it represents my real problem
well enough. Writing the text to a temp file and using 'cat' isn't an
option, unfortunately.

Thanks for any help,

Brian Hartin
************************************************** ***********************=
***=20
This email may contain material confidential to
Pearson. If you were not an intended recipient,=20
please notify the sender and delete all copies.=20
We may monitor email to and from our network.=20
************************************************** ***********************=
***

 
Reply With Quote
 
 
 
 
Hartin, Brian
Guest
Posts: n/a
 
      04-10-2008
Nevermind...it was a Cygwin problem. Works fine on RedHat.


-----Original Message-----
From: Hartin, Brian=20
Sent: Wednesday, April 09, 2008 6:58 PM
To: '(E-Mail Removed)'
Cc: Hartin, Brian
Subject: Question about backquotes and linux echo

Hi all,

I can't figure out why the following works from the command line but not
from the backquotes:

echo -e "a\nb\naa" | grep a

This should produce:

a
aa


However, when I execute:

puts `echo -e "a\\nb\\naa" | grep a`

I get:

-e "a\nb\naa"

Of course, this is a trivial example, but it represents my real problem
well enough. Writing the text to a temp file and using 'cat' isn't an
option, unfortunately.

Thanks for any help,

Brian Hartin
************************************************** ***********************=
***=20
This email may contain material confidential to
Pearson. If you were not an intended recipient,=20
please notify the sender and delete all copies.=20
We may monitor email to and from our network.=20
************************************************** ***********************=
***

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Q: Change shell for backquotes G. Ralph Kuntz, MD, MS Ruby 2 07-22-2008 11:28 AM
backquotes question Zouplaz Ruby 5 10-16-2007 11:57 AM
Exec cmd echo for beep with java on linux Nanou Java 11 10-21-2005 08:03 PM
backquotes, system, shell and ruby John Carter Ruby 6 10-06-2003 08:36 AM
echo echo echo craig judd Computer Support 1 09-23-2003 08:53 PM



Advertisments