Greg Dougherty
Greg Dougherty

Reputation: 3471

Bash: "syntax error near unexpected token" that's a valid token

I have the following bash code in a script file:

if [ 'false' == 'true' ]
then
        write_map() >> 'groups.txt'
        Groups='groups.txt'
fi

When I try to run the script, I get this message from bash, and nothing is run:

syntax error near unexpected token `>>'
  1. Why is >> an "unexpected token?
  2. Why is bash failing on code that is inside an "if" that won't be run?
  3. This bash code was created by Cromwell wdl. write_map is a wdl function, not a bash function. Could that be what's breaking bash?

Upvotes: 0

Views: 663

Answers (1)

Greg Dougherty
Greg Dougherty

Reputation: 3471

So, there were two issues

  1. write_map was being called wrong in the wdl code that was the source for this bash code
  2. When called correctly, write_map is turned into a file, and you can't >> a file (you have to cat it then >>)

Upvotes: 0

Related Questions