user765443
user765443

Reputation: 1892

syntax error near unexpected token `(' in below code

I have very small shell script.When I am running it run flow. it is giving "syntax error near unexpected token `(". Very basic question but sorry not able to figure out.

foreach i ( `cat list407`)
mkdir cells/${i}
 cp /<path>/$i/${i}.gds cells/${i}/${i}.gds
end

Error:

flow: line 1: syntax error near unexpected token `('
flow: line 1: `foreach i ( `cat list407`)'

Upvotes: 2

Views: 3892

Answers (2)

Peter Faller
Peter Faller

Reputation: 132

for i in $(cat list407); do
  mkdir cells/${i};
  cp /<path>/$i/${i}.gds cells/${i}/${i}.gds;
done

Upvotes: 1

devnull
devnull

Reputation: 123458

You've used csh syntax for execution using bash which is causing the error.

Either use csh to execute your script, or using bash say:

while read -r i; do
  mkdir "cells/${i}"
  cp "/<path>/${i}/${i}.gds" "cells/${i}/${i}.gds"
done < list407

Upvotes: 4

Related Questions