Pregunta

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

?

¿Fue útil?

Solución

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

Otros consejos

Just do:

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

Alternatively:

perl -wnl -e "/^#/ && print or exit" file.vcf
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top