2

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`)'
1
  • 1
    You seem to be executing csh syntax using bash. Commented Jan 6, 2014 at 10:50

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

Thx for quick response. Yes I did this mistake.
1
for i in $(cat list407); do
  mkdir cells/${i};
  cp /<path>/$i/${i}.gds cells/${i}/${i}.gds;
done

1 Comment

Bad practice. Never use command substitution with for loop. Also, never read a file with for loop, always use while for this purpose. refer this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.