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?