This is a test version of Biostars. For the public version, visit https://www.biostars.org.
syntax error near unexpected token `('

Hi,

I come up with

syntax error near unexpected token `('

when I run

> #!/bin/bash

> num1=$(paste <(gunzip -c $name1$ext) <(gunzip -c $name2$ext) | awk
> '!((NR+2)%4)' | grep -cE $ligation)

the code is from countligations.sh in juicer pipeline for Hi-C analysis. I asked the developer who told me to update some of my command line version, but still I can't solve it. I assume this might be simply because of the shell script matter.

Can anyone help me to fix this?

Best regards,

script shell

bracket before paste is not closed and ligation bracket is not closed.

#!/bin/bash

num1=$(paste <(gunzip -c $name1$ext) <(gunzip -c $name2$ext)) | awk '!((NR+2)%4)' | grep -cE $(ligation)

There are several issues with this code (based on OP code). Seems this is part of bigger problem.. what is the input for awk btw?

Thank you so much for your help.

The input for awk is

paste <(gunzip -c $name1$ext) <(gunzip -c $name2$ext)

The above command is passed on to awk and then to grep, and all these calculation is summarized as $num1.

It seems it works by itself, but won't work when running the whole .sh script.

#!/bin/bash
    export LC_ALL=C
    export LC_COLLATE=C
    if [ "$usegzip" -eq 1 ]
    then 
        num1=$(paste <(gunzip -c $name1$ext) <(gunzip -c $name2$ext) | awk '!((NR+2)%4)' | grep -cE $ligation)
        num2=$(gunzip -c ${name1}${ext} | wc -l | awk '{print $1}')
    else
        num1=$(paste $name1$ext $name2$ext | awk '!((NR+2)%4)' | grep -cE $ligation)
        num2=$(wc -l ${name1}${ext} | awk '{print $1}')
    fi
    echo -ne "$num1 " > ${name}${ext}_norm.txt.res.txt
    echo "$num2" > ${name}${ext}_linecount.txt

Any help is appreciated. Thanks in advance.

I got it wrong. sorry for that. can you post some example data?

1 answer

How are you running the script? If you run it as sh script.sh, it will run in POSIX compatiibility mode that does not support process substitution. Try running bash script.sh. Better yet, rename it to script.bash so you remember to use bash. If you're already running it using bash script.sh, I have no idea what could be happening.

Hi,

bash script.sh

worked perfectly!!

Thank you so much!!

Glad it worked. Please use the check mark on the left to accept the answer and mark your post as resolved.

Log in to answer this question.