Hi All,
Is there a way to join several lines every time a pattern is found.
I know this can be done by using the following
awk '/DSB=/{printf "%s%s",sep,$0;sep="\n";next}
{printf "%s",$0}
END{print}'
But what I am looking for is when /DSB/ is found the next line starts ^+++=. I need these lines to be joined until the next /DSB/ without a print statement, then declare e.g
YEAR=tolower(substr($2,1,2))
MONT=tolower(substr($2,3,2))
.... etc
My input
DSB=fb 00 80 00 01 0a 011616527100 0000 0000 04081c141833 0a 011450225000000000
+++= 00000010001c0000002d20000101ac024000ad0414001400064a4744484142ce
+++= 02aa03041023ab08454e5155495234201702e3172d20000000000000009b7500
DSB=fb 00 80 00 01 0a 039254023500 0000 d801 04081c141834 0a 031462586600000000
+++= 0000001000180000001720000102ac026000ad041b001a000644544d484142b9
+++= 000b
And Part of script
Disp Filename | awk '{if($1~/^DSB/){
# this is where I get stuck
hexstr="0123456789abcdef"
newnum=tolower(substr($4,3,2) substr($4,1,2))
YEAR=tolower(substr($10,1,2))
MONT=tolower(substr($10,3,2))
DAY=tolower(substr($10,5,2))
HOUR=tolower(substr($10,7,2))
(Disp is a tool to read in hex format)
Many Thanks
Chris
Is there a way to join several lines every time a pattern is found.
I know this can be done by using the following
awk '/DSB=/{printf "%s%s",sep,$0;sep="\n";next}
{printf "%s",$0}
END{print}'
But what I am looking for is when /DSB/ is found the next line starts ^+++=. I need these lines to be joined until the next /DSB/ without a print statement, then declare e.g
YEAR=tolower(substr($2,1,2))
MONT=tolower(substr($2,3,2))
.... etc
My input
DSB=fb 00 80 00 01 0a 011616527100 0000 0000 04081c141833 0a 011450225000000000
+++= 00000010001c0000002d20000101ac024000ad0414001400064a4744484142ce
+++= 02aa03041023ab08454e5155495234201702e3172d20000000000000009b7500
DSB=fb 00 80 00 01 0a 039254023500 0000 d801 04081c141834 0a 031462586600000000
+++= 0000001000180000001720000102ac026000ad041b001a000644544d484142b9
+++= 000b
And Part of script
Disp Filename | awk '{if($1~/^DSB/){
# this is where I get stuck
hexstr="0123456789abcdef"
newnum=tolower(substr($4,3,2) substr($4,1,2))
YEAR=tolower(substr($10,1,2))
MONT=tolower(substr($10,3,2))
DAY=tolower(substr($10,5,2))
HOUR=tolower(substr($10,7,2))
(Disp is a tool to read in hex format)
Many Thanks
Chris