Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

I have run the following command on the command line and it works fine, but when I try running it from a shell script and run shell script from the terminal I get the following error:

join -t $'\t' -a1 -e "u" -1 1 -2 1 -o 1.1,2.1,2.2 file1
<(cat file2 | sort -k1,1|tr [:blank:] \t ) | awk 'BEGIN {FS="\t";OFS="\t"}{if ($2 == "u")print $0, $1;else print $0, $3}' | awk '{gsub(/ /,"\t");l=$4; sub(/.*_/,"",l); print $2"\t"$3"\t"l}' > outjoin -t $'\t' -a1 -e "u" -1 1 -2 1 -o 1.1,2.1,2.2 file1 \ <(cat file2 | sort -k1,1|tr [:blank:] \\t ) | awk 'BEGIN {FS="\t";OFS="\t"}{if \($2 == "u")print $0, $1;else print $0, $3}' | awk '{gsub(/ /,"\t");l=$4; sub(/.*_/,"",l); print $2"\t"$3"\t"l}' > out

syntax error near unexpected token `syntax error near unexpected token (''`

I have tried escaping the bracket but it still gives me the same error. I have many of these multi-layered commands in the script so I am sure this will be a problem in other parts, is there a way to solve this?

Thank you in advance

I have run the following command on the command line and it works fine, but when I try running it from a shell script and run shell script from the terminal I get the following error:

join -t $'\t' -a1 -e "u" -1 1 -2 1 -o 1.1,2.1,2.2 file1
<(cat file2 | sort -k1,1|tr [:blank:] \t ) | awk 'BEGIN {FS="\t";OFS="\t"}{if ($2 == "u")print $0, $1;else print $0, $3}' | awk '{gsub(/ /,"\t");l=$4; sub(/.*_/,"",l); print $2"\t"$3"\t"l}' > out

syntax error near unexpected token `('

I have tried escaping the bracket but it still gives me the same error. I have many of these multi-layered commands in the script so I am sure this will be a problem in other parts, is there a way to solve this?

Thank you in advance

I have run the following command on the command line and it works fine, but when I try running it from a shell script and run shell script from the terminal I get the following error:

join -t $'\t' -a1 -e "u" -1 1 -2 1 -o 1.1,2.1,2.2 file1 \ <(cat file2 | sort -k1,1|tr [:blank:] \\t ) | awk 'BEGIN {FS="\t";OFS="\t"}{if \($2 == "u")print $0, $1;else print $0, $3}' | awk '{gsub(/ /,"\t");l=$4; sub(/.*_/,"",l); print $2"\t"$3"\t"l}' > out

syntax error near unexpected token ('`

I have tried escaping the bracket but it still gives me the same error. I have many of these multi-layered commands in the script so I am sure this will be a problem in other parts, is there a way to solve this?

Source Link

escaping brackets and other characters in shell script

I have run the following command on the command line and it works fine, but when I try running it from a shell script and run shell script from the terminal I get the following error:

join -t $'\t' -a1 -e "u" -1 1 -2 1 -o 1.1,2.1,2.2 file1
<(cat file2 | sort -k1,1|tr [:blank:] \t ) | awk 'BEGIN {FS="\t";OFS="\t"}{if ($2 == "u")print $0, $1;else print $0, $3}' | awk '{gsub(/ /,"\t");l=$4; sub(/.*_/,"",l); print $2"\t"$3"\t"l}' > out

syntax error near unexpected token `('

I have tried escaping the bracket but it still gives me the same error. I have many of these multi-layered commands in the script so I am sure this will be a problem in other parts, is there a way to solve this?

Thank you in advance