Safe pattern to process multiple files in Awk
I'm writing a shell utility that takes a few file arguments and cross-validate them with Awk. The Awk implementation is not guaranteed to be GNU so I stick to POSIX patterns. What I'm doing right now is: #!/bin/bash sam_sq_to_tsv() { ...; } # output: SQ-SN \t SQ-LN fasta_to_tsv() { ...;} # output: id \t sequence awk -F '\t' ' FNR == 1 { if (input_no == 1) { if (!n_bam_recs) exit 1; } else if (input_no == 2) { if (!n_bed_recs) exit 1; } ++input_no; next; } input_no == 1 { ++n_bam_recs; # some SAM SQ header processing next; } input_no == 2 { if (!NF || /^#/) next; ++n_bed_recs; # some BED proces
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.