gawk simple programs differences
Given the following input:
SQ SEQUENCE 365 AA; 40909 MW; 78539C59DB8B1DFC CRC64;
MAVMAPRTLV LLLSGALALT QTWAGSHSMR YFYTSVSRPG RGEPRFIAVG YVDDTQFVRF
DSDAASQRME PRAPWIEQEG PEYWDRNTRN VKAQSQTDRV DLGTLRGYYN QSEAGSHTIQ
MMYGCDVGSD GRFLRGYRQD AYDGKDYIAL KEDLRSWTAA DMAAQTTKHK WEAAHVAEQW
RAYLEGTCVE WLRRYLENGK ETLQRTDAPK THMTHHAVSD HEATLRCWAL SFYPAEITLT
WQRDGEDQTQ DTELVETRPA GDGTFQKWVA VVVPSGQEQR YTCHVQHEGL PKPLTLRWEP
SSQPTIPIVG IIAGLVLFGA VITGAVVAAV MWRRKSSDRK GGSYSQAASS DSAQGSDVSL
TACKV
I need to join the lines which starts with 5 spaces. The following simple gawk commands first filters whit开发者_StackOverflow社区e-starting lines, and the other one strips out the white spaces, and it works as intended (I know there are many ways I can do this, I'm just learning gawk
now):
gawk /^" "/ input | gawk '{ gsub (" ", "", $0); print }'
My question is why, if I unite the two commands into one, it doesn't print anything. I'm sure it's a syntax issue somewhere:
gawk '/^" "/ { gsub (" ", "", $0); print }' input
Take out the dbl-quote chars from your pattern in the 1 line version.
In a regular expression for patterns, every char is considered 'must be there', and as you have the whole of the command quoted in single-quotes, the shell will not strip away the double-quotes.
gawk '/^ / { gsub (" ", "", $0); print }' input
(fyi: In unix text editing parlance, join usually is taken to mean, 'remove the carriage return, and have text continue on one line'. )
I hope this helps!
精彩评论