Getting syntax error using awk in parallel processing
@DudiBoy has a good solution. But to me it is annoying that I have to make another file just because I want to call GNU Parallel.
So you can also use functions. This way you do not need to make a new file:
doit() { bedtools intersect -a "$1" -b "$2" -c | awk '{sum+=$4} END {print sum}'}export -f doitparallel --results {1}.{2}.intersect doit {1} {2} ::: *.tsv ::: *.tsv
I think you need to quote it like this:
parallel bedtools intersect -a {1} -b {2} -c \| awk \'{sum+=\$4} END{print sum+0}\' \> {1}.{2}.intersect ::: *tsv ::: *tsv
I believe @MarkSetchell is valid answer. You can also try to clean it up by inserting your complicated line into a bash script you can test.
intersect.bash
#!/bin/bash bedtools intersect -a $1 -b $2 -c | awk '{sum+=$4} END {print sum}'
Test intersect.bash
to function correctly, then parallel it.
parallel intersect.bash {1} {2}
good luck.