1

I'm trying to run a command from the 'plink1.9' program for population genetics, whilst changing two of the parameters.

In the code below, the first parameter, i, is either 1 or 100, and the second parameter, j, is either 0.4 or 0.8. I'd hope that this generates four different outputs, with each including the corresponding input parameter values in the output file name.

This is my code, which fails with 'syntax error near unexpected token 'do''.

for i in 1 100
do
    for j in 0.4 0.8
        do
        plink --bfile myfile \
                --indep-pairwise ${i} 50 ${j} \
                --out myfile_${i}_50_${j}_indep
        done
done

If anyone has any suggestions as to how I can fix this, I'd be very appreciative. I have tried several variations on this. Ideally I'd run multiple commands through the loop, change all three of the variables instead of just two, and have more than two possible values for each variable but I'll keep it simple until it works.

1
  • 2
    Does your script use DOS line endings (in which case do\r is not recognized as the expected keyword)? I'll note that bash 4.4 now gives a much clearer error message in such cases. Commented Nov 4, 2016 at 15:32

1 Answer 1

1

This could be because you are using a default shell that is not Bash.

Note that you can simplify your script by using GNU Parallel:

parallel plink --bfile myfile \
            --indep-pairwise {1} 50 {2} \
            --out myfile_{1}_50_{2}_indep ::: 1 100 ::: 0.4 0.8
Sign up to request clarification or add additional context in comments.

Comments

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.