Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am trying to run a command on matlab installed on windows in which I run a awk statement which is interpreted by cygwin. When I run the whole ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    11

    Question matlab issue: linux vs windows


    Hi,
    I am trying to run a command on matlab installed on windows in which I run a awk statement which is interpreted by cygwin.
    When I run the whole statement under linux, it executes without anyy problem but when the statement is exected under cygwin, I get an error message.
    Here is the statement with error:

    tempfile = '../tmp/junk';
    system(sprintf('awk ''{if( NF>23) print $4;}'' ../tmp/naive1_short.txt > %s ', tempfile));


    Error:

    gawk: {if( NF print $4;}
    gawk: ^ syntax error


    Somehow it fails to interpret GREATER THAN sign.
    Anyone having some idea?
    Thanks,
    Abhi.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,696
    Try enclosing the statement in single instead of double quotes. Since they are already inside a single-quoted string, escape them with backslashes. IE:
    Code:
    system(sprintf('awk \'{if( NF>23) print $4;}\' ../tmp/naive1_short.txt > %s ', tempfile));
    Also, you may need to put a space before+after the curly braces { and }.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •