Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question matlab issue: linux vs windows

    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));


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

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

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Try enclosing the statement in single instead of double quotes. Since they are already inside a single-quoted string, escape them with backslashes. IE:
    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