I want to process a tab-limited file text using awk and set the output as variable in unix.
I wanted to i) select lines that have unique combinations of values in the 1st and 3rd column; ii) sort by increasing numeric value at the first column; iii) extract the first column; etc.. So I used the following script:
locus_overmerged=$(awk -F"\t" '!seen[$1, $3]++' <(gzip -dc $id) | sort -n -k1,1 | cut -f1 | uniq -dc | awk '{print $2}')
If I run it by hand in the terminal, it works. However, when I input this command in a script, I obtain the following error:
syntax error near unexpected token `('
` awk -F"\t" '!seen[$1, $3]++' <(gzip -dc $id) | sort -n -k1,1 | cut -f1 | uniq -dc | awk '{print $2}' )'
Any idea on what it could be the problem?