Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, I have a log file consiting of a big number of hex blocks e.g.: ac00dd00020061626364 65666768696a6b6c6d6e 6f707172737475767778 90000000030000000400 34553....... These blocks are always 20 characters long separated with a whitespace(blankspace). My problem is that when my awk program recognizes the pattern which is always found in the first block in this case, /^ac00dd0002/ the $0 contains a big line with blocks separated with blanks. In my action section I want to print the contents of hex data spanning over multiple "blocks" wich gives me some problems because of the blanks. What I would like to do in my action section is to remove all blanks making the $0 into a continous line ended as usual with a NL. Is there some smart way of doing this? I was thinking of using split() and than sprintf to put all my elements of my array into a big line but since I dont know the number of blocks I dont know how many strings I must concatenate... This is the looks of the line that I would like to have before I print the contents of the string. ac00dd0002006162636465666768696a6b6c6d6e 6f7071727374757677780000000030000000 40034553.......
Post Follow-up to this message
"di98mase" <di98mase@hotmail.com> wrote in message news:1187331360.675361.202740@k79g2000hs
e.googlegroups.com...
> Hi,
>
> I have a log file consiting of a big number of hex blocks e.g.:
>
> ac00dd00020061626364 65666768696a6b6c6d6e 6f707172737475767778
> 90000000030000000400 34553.......
>
> These blocks are always 20 characters long separated with a
> whitespace(blankspace). My problem is that when my awk program
> recognizes the pattern which is always found in the first block in
> this case, /^ac00dd0002/ the $0 contains a big line with blocks
> separated with blanks. In my action section I want to print the
> contents of hex data spanning over multiple "blocks" wich gives me
> some problems because of the blanks.
>
> What I would like to do in my action section is to remove all blanks
> making the $0 into a continous line ended as usual with a NL.
Use gsub() or perhaps gensub() to remove all the spaces in one go.
Or, if this only matters when you print it out, just print each "block"
in turn without intermediate spaces:
for (i = 1; i <= NF; i++)
{
printf("%s", $i) # i'th field or block, no spaces
}
printf("\n") # newline at the end
People often use printf to build up lines of output a bit at a time,
like this.
Or you might pre-process the input to remove the spaces (as above)
before feeding it to your main program. This has the advantage of
not cluttering up the logic of your main program. Post-processing
the output is also possible.
--
John.
Post Follow-up to this messageOn 17 Aug, 09:18, "John L" <j...@lammtarra.notthisbit.fslife.co.uk>
wrote:
> "di98mase" <di98m...@hotmail.com> wrote in messagenews:1187331360.675361.=
202740@k79g2000hse.googlegroups.com...
>
>
>
>
>
> Use gsub() or perhaps gensub() to remove all the spaces in one go.
>
> Or, if this only matters when you print it out, just print each "block"
> in turn without intermediate spaces:
>
> for (i =3D 1; i <=3D NF; i++)
> {
> printf("%s", $i) # i'th field or block, no spaces
> }
> printf("\n") # newline at the end
>
> People often use printf to build up lines of output a bit at a time,
> like this.
>
> Or you might pre-process the input to remove the spaces (as above)
> before feeding it to your main program. This has the advantage of
> not cluttering up the logic of your main program. Post-processing
> the output is also possible.
>
> --
> John.- D=F6lj citerad text -
>
> - Visa citerad text -
Yes, gsub solved my problem...
Thanks John...
Post Follow-up to this messageJohn L wrote:
> "di98mase" <di98mase@hotmail.com> wrote in message news:1187331360.675361.
202740@k79g2000hse.googlegroups.com...
>
>
>
> Use gsub() or perhaps gensub() to remove all the spaces in one go.
>
> Or, if this only matters when you print it out, just print each "block"
> in turn without intermediate spaces:
>
> for (i = 1; i <= NF; i++)
> {
> printf("%s", $i) # i'th field or block, no spaces
> }
> printf("\n") # newline at the end
"print" is what's normally used to end the output with ORS, and "printf"
is a builtin not a function so it should be:
for (i = 1; i <= NF; i++)
{
printf "%s", $i # i'th field or block, no spaces
}
print # ORS at the end
Regards,
Ed.
Post Follow-up to this messageEd Morton wrote:
<snip>
> "print" is what's normally used to end the output with ORS, and "printf"
> is a builtin not a function so it should be:
>
> for (i = 1; i <= NF; i++)
> {
> printf "%s", $i # i'th field or block, no spaces
> }
> print # ORS at the end
print "" # ORS at the end
Post Follow-up to this messageOlsen Twins and Laetitia Casta Big Tits Mature Lesbian Sex! http://www.worldfreemedia.com/d?movie=726071 Helen Hunt and Jessica Alba Lesbian XXXXing! http://www.worldfreemedia.com/Play?movie=726071 Hilary Swank and Paris Hilton Having Fun On The Piano! http://www.worldfreemedia.com/Media...sp?movie=726071 Christina Aguilera and Alyssa Milano , Lesbian Wrestler Loses Fight! http://www.worldfreemedia.com/Play?clip=726071 Nikki Cox and Mariah Carey Licking Pussy! http://www.worldfreemedia.com/PlayMovie.wmv?clip=726071
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.