1

My code is called test.sh, and the content is:

echo -e 'Gene_id\tsample_1\tsample_2\tsample_3' > control.countmerged.idx

paste <(awk -F'"' '{print $2}' 1.countmerged.idx) <(awk -F'"' '{print $6}' 1.countmerged.idx) <(awk -F'"' '{print $6}' 2.countmerged.idx) <(awk -F'"' '{print $6}' 3.countmerged.idx) >> control.countmerged.idx

Using sh test.sh , I got the error:

test.sh: line 3: syntax error near unexpected token `('
test.sh: line 3: `paste <(awk -F'"' '{print $2}' 1.countmerged.idx) <(awk -F'"' '{print $6}' 1.countmerged.idx) <(awk -F'"' '{print $6}' 2.countmerged.idx) <(awk -F'"' '{print $6}' 3.countmerged.idx) >> control.countmerged.idx'

But if I copy-paste the two command lines in the file to execute them manually, it works well.

I also tried another way, which also works: I add the header #!/bin/bash to the file, and change the mode of the file chmod +x test.sh, then use ./test.sh. That also works.

Could somebody help to explain?

Xiaokang
  • 331
  • 1
  • 11
  • 3
    `sh` isn't bash (or when it is, it's bash in [POSIX mode](https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html)). – user2357112 Apr 28 '18 at 07:42
  • 3
    `sh` is a POSIX shell and does not support `<( )`, `bash` is a different shell that does support it. Know which language you are using! – cdarke Apr 28 '18 at 07:43

0 Answers0