Domanda

I want to print all header lines of a file:

perl -wnl -e "/^#/ and print" file.vcf

This works- however, I want to quit after I'm done with the header.

What's wrong with

perl -wnl -e "/^#/ and print else exit" file.vcf

?

È stato utile?

Soluzione

else is a keyword that's found as part of if and unless statements.

perl -wnl -e "if (/^#/) { print } else { exit }" file.vcf

perl -wnl -e "/^#/ ? print : exit" file.vcf

perl -wnl -e "/^#/ or exit; print" file.vcf

perl -wpl -e "/^#/ or exit" file.vcf

perl -wpl -e "/^#/ or last" file.vcf

perl -p -e "/^#/ or last" file.vcf

perl -pe"/^#/ or last" file.vcf

Altri suggerimenti

Just do:

perl -wnl -e "/^#/ ? print : exit" file.vcf

Alternatively:

perl -wnl -e "/^#/ && print or exit" file.vcf
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top