Entering edit mode
4.3 years ago
lamia_203
▴
100
Hi, I am trying to make multiple commands within a for loop but it is not working as awk appears as plink.awk once pasted on the shell. I've written the command below. I have attempted to pipe is as I do not need intermediate files. Any help would be much appreciated, thank you!
for f *.linear; do
paste $f <(yes $f | head -n $(cat $f | wc -l)) > $f.new |
awk 'NR==FNR{a[$2]=$6;next}{$10=a[$2]; print}' filtered.bim $f.new > $f.A2 |
awk 'NR==1{print $1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" A2" ;next}{print}' $f.A2 > $f.A22 |
awk '{ print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $1}' $f.A22 > $f.chrbp |
awk '{print $1":"$3"\t"$11" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "$10}' $f.chrbp > $f.2
done
may be you want to remove all those '|' at the end of the lines....
And replace with
;
.Thank you that has worked, but awk still appears with 'plink.awk' so I still have to edit commans once pasted on the shell. All my file names start with plink. but I'm not sure why the attach to the awk command.
This is not how piping works. Either you send things to stdout into the next command via
|
or you capture the output of every line with>
to a file. Both is not possible at the same time.I'll take note thank you. It worked with the semi-colon but still produces outputs. I wanted to carry the amended file each command carries out onto the next command and avoid using the origin file each time as well as producing those files in the shell but it looks like the latter occurred.