How can I change the following command for a compressed file?
awk 'FNR==NR { array[$1,$2]=$8; next } ($1,$2) in array { print $0 ";" array[$1,$2] }' input1.vcf input2.vcf
The command working fine with normal file. I need to change the command for compressed files.
No, Awk just reads and writes text, and only the files you tell it to. You give it - to say "read standard input, not a file on disk". Pipe to gzip to compress the output. zcat | awk stuff ...
In our awk code, we don't have to handle each file separately or manually control the redirection. Instead, we just change the text as the awk command reads each line from the files. The inplace extension takes care of which file is currently being processed and writes any changes back to the file automatically.
Unfortunately, grep doesn't work on compressed files. To overcome this, people usually advise to first uncompress the file(s), and then grep your text, after that finally re-compress your file(s)… You don't need to uncompress them in the first place. You can use zgrep on compressed or gzipped files.
awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output. xargs kill -${2:-'TERM'} takes the process IDs from the selected sidekiq processes and feeds them as arguments to a kill command.
You need to read them compressed files like this:
awk '{ ... }' <(gzip -dc input1.vcf.gz) <(gzip -dc input2.vcf.gz)
Try this:
awk 'FNR==NR { sub(/AA=\.;/,""); array[$1,$2]=$8; next } ($1,$2) in array { print $0 ";" array[$1,$2] }' <(gzip -dc input1.vcf.gz) <(gzip -dc input2.vcf.gz) | gzip > output.vcf.gz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With