syntax error near unexpected token `('
1
0
Entering edit mode
3.5 years ago

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 • 5.1k views
ADD COMMENT
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
3.5 years ago
Ram 44k

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.

ADD COMMENT
0
Entering edit mode

Hi,

bash script.sh

worked perfectly!!

Thank you so much!!

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2633 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6