1

The following code returns: syntax error near (

#!/bin/bash
myprogram -i <(gunzip -c file.gz) -j <(gunzip -c file2.gz)

It seems it doesn't like brackets. How can I make this script work? If I run the same command for a Linux shell it works. It is when I try to run the script with the command inside that it fails. Do I need to protect brackets or so ??

The exact command line that works outside the script (command line) is:

 kaiju -z 1 -a greedy -m 5 -s 70 -x \
   -t /db/kaiju/nodes.dmp -f /db/kaiju/kaiju_db_nr_euk.fmi \
   -i <(gunzip -c files/mapped_reads_to_extracted_marker_genes/1/1.1.1.bin.13.genes.fa.R1.fq.gz) \
   -j <(gunzip -c files/mapped_reads_to_extracted_marker_genes/1/1.1.1.bin.13.genes.fa.R2.fq.gz)

Sorry for long line (kaiju is open source program for bioinformatics). Inside a script it fails with the error above

bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

The way I'm running the script is ./script.sh or bash script.sh. I have run chmod +x on the script also. Any idea how it should written then?

  • 1
    How exactly are you running the script? – steeldriver Jan 23 '17 at 17:04
  • 3
    specifically, if you are using sh /path/to/script, you're not using bash, and <(something) is a bashism. – DopeGhoti Jan 23 '17 at 17:10
  • 2
    @DopeGhoti Let's just call it a modernism of many current shells apart from some strictly POSIX-compliant shells. – Kusalananda Jan 23 '17 at 17:25
  • What's your version of bash? (bash --version) What system does it fail on? Are you sure that the error comes from this shell script and not from within myprogram? – Kusalananda Jan 23 '17 at 18:13
  • What is the error you get? – George Vasiliou Jan 23 '17 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.