Question about backquotes and linux echo

Discussion in 'Ruby' started by Hartin, Brian, Apr 10, 2008.

  1. 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
    *************************************************************************=
    ***
     
    Hartin, Brian, Apr 10, 2008
    #1
    1. Advertising

  2. 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: ''
    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
    *************************************************************************=
    ***
     
    Hartin, Brian, Apr 10, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nanou
    Replies:
    11
    Views:
    10,865
    Pradyut
    Oct 21, 2005
  2. Francis Avila

    Echo console to a device (and vice-versa)?

    Francis Avila, Oct 3, 2003, in forum: Python
    Replies:
    2
    Views:
    391
    Francis Avila
    Oct 5, 2003
  3. John Carter

    backquotes, system, shell and ruby

    John Carter, Oct 3, 2003, in forum: Ruby
    Replies:
    6
    Views:
    127
    Robert Klemme
    Oct 6, 2003
  4. Zouplaz

    backquotes question

    Zouplaz, Oct 14, 2007, in forum: Ruby
    Replies:
    5
    Views:
    89
    Zouplaz
    Oct 16, 2007
  5. G. Ralph Kuntz, MD, MS

    Q: Change shell for backquotes

    G. Ralph Kuntz, MD, MS, Jul 21, 2008, in forum: Ruby
    Replies:
    2
    Views:
    83
    G. Ralph Kuntz, MD, MS
    Jul 22, 2008
Loading...

Share This Page