Help with report gen. awk/sed - Unix

This is a discussion on Help with report gen. awk/sed - Unix ; Hello, I am trying to generate a report and in doing so i discovered I need to search for a particular background color (in a html source file) and remove the line break / return stroke. How would I go ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Help with report gen. awk/sed

  1. Help with report gen. awk/sed

    Hello,

    I am trying to generate a report and in doing so i discovered I need
    to search for a particular background color (in a html source file)
    and remove the line break / return stroke.

    How would I go about doing this?

  2. Re: Help with report gen. awk/sed

    David.LPower@gmail.com wrote:
    > I am trying to generate a report and in doing so i discovered I need
    > to search for a particular background color (in a html source file)
    > and remove the line break / return stroke.


    Hmmm, do you have to look for the background color and remove the
    line break (that could be either the carriage return or the line
    feed character or both, depending on where and whet generated the
    file) directly after the background-color or do you need to re-
    move all of them in the file? And how is the background color
    set? A background can be set in lot of different ways, both using
    HTML attributes and style settings. As you see it's not very clear
    what exactly you need to do and thus giving a useful answer is
    practically impossible. Could you explain what you have to do a
    bit more precisely and perhaps even show an example of the HTML
    files you are dealing with?
    Regards, Jens

    PS: If it's acceptable to remove all line breaks in the file
    (which shouldn't change anything about the way it gets
    displayed) the most simple solution might be to use tr:

    tr -d "\n\r" < input_file > output_file
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  3. Re: Help with report gen. awk/sed

    On May 30, 11:09*am, j...@toerring.de (Jens Thoms Toerring) wrote:
    > David.LPo...@gmail.com wrote:
    > > I am trying to generate a report and in doing so i discovered I need
    > > to search for a particular background color (in a html source file)
    > > and remove the line break / return stroke.

    >
    > Hmmm, do you have to look for the background color and remove the
    > line break (that could be either the carriage return or the line
    > feed character or both, depending on where and whet generated the
    > file) directly after the background-color or do you need to re-
    > move all of them in the file? And how is the background color
    > set? A background can be set in lot of different ways, both using
    > HTML attributes and style settings. As you see it's not very clear
    > what exactly you need to do and thus giving a useful answer is
    > practically impossible. Could you explain what you have to do a
    > bit more precisely and perhaps even show an example of the HTML
    > files you are dealing with?
    > * * * * * * * * * * * * * * * * Regards, Jens
    >
    > PS: If it's acceptable to remove all line breaks in the file
    > * * (which shouldn't change anything about the way it gets
    > * * displayed) the most simple solution might be to use tr:
    >
    > * * *tr -d "\n\r" < input_file > output_file
    > --
    > * \ * Jens Thoms Toerring *___ * * *j...@toerring.de
    > * *\__________________________ * * *http://toerring.de


    "do you have to look for the background color and remove the
    > line break" yes. I need to scan through a large file that has many tables in it. tables with a red back groud are high vunrabillity related so I want to remove the line brake from the backgroud definition in the html source and in doing so I will be able to view the ip address of the pc that has this high vunrability as the ip address is printed below the line that defines the BGcolour. e.g.


    so if I could find this and remove the line break after that line so
    the line below it is now on the previous

    I am using this code to find the part but dont
    know how remove the ln break. I under stand if i could remove the /n
    after this i could be ok.
    ( awk '/ / {print}' [file name] )

  4. Re: Help with report gen. awk/sed

    > PS: If it's acceptable to remove all line breaks in the file
    > (which shouldn't change anything about the way it gets
    > displayed) the most simple solution might be to use tr:
    >
    > tr -d "\n\r" < input_file > output_file


    Gah!

    Hello
    world!

    becomes

    Helloworld!

    perhaps

    tr '\r\n' ' ' < input_file > output_file

    And that will still screw up any

    , and any line-based scripts,
    etc.

  5. Re: Help with report gen. awk/sed

    On May 30, 12:08 pm, David.LPo...@gmail.com wrote:
    > On May 30, 11:09 am, j...@toerring.de (Jens Thoms Toerring) wrote:


    >> "do you have to look for the background color and remove the line break"


    > yes. I need to scan through a large file that has many tables in it. tables with a red back groud are high vunrabillity related so I want to remove the line brake from the backgroud definition in the html source and in doing so I will be able to view the ip address of the pc that has this high vunrability as the ip address is printed below the line that defines the BGcolour. e.g.
    >
    > so if I could find this and remove the line break after that line so
    > the line below it is now on the previous
    >
    > I am using this code to find the part but dont
    > know how remove the ln break. I under stand if i could remove the /n
    > after this i could be ok.
    > ( awk '/ / {print}' [file name] )


    Try
    sed '/$/bf;b;:f;N;s/\n//' < input_file >
    output_file

    HTH
    viza

  6. Re: Help with report gen. awk/sed

    On May 30, 7:08*am, David.LPo...@gmail.com wrote:
    > I am using this code to find the * part but dont
    > know how remove the ln break. I under stand if i could remove the /n
    > after this i could be ok.
    > ( awk '/ / {print}' [file name] )


    Can you use sed, e.g.:

    jc@jc-ubuntu:~$ cat /tmp/test.html









    192.168.0.1
    192.168.0.2




    jc@jc-ubuntu:~$ sed -e '/tr bgcolor="#CC0000"/N; s/\n//' < /tmp/
    test.html








    192.168.0.1
    192.168.0.2




  7. Re: Help with report gen. awk/sed

    On May 30, 1:00*pm, "shakahsha...@gmail.com"
    wrote:
    > On May 30, 7:08*am, David.LPo...@gmail.com wrote:
    >
    > > I am using this code to find the * part but dont
    > > know how remove the ln break. I under stand if i could remove the /n
    > > after this i could be ok.
    > > ( awk '/ / {print}' [file name] )

    >
    > Can you use sed, e.g.:
    >
    > jc@jc-ubuntu:~$ cat /tmp/test.html
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    192.168.0.1
    192.168.0.2

    >
    >
    >
    > jc@jc-ubuntu:~$ sed -e '/tr bgcolor="#CC0000"/N; s/\n//' < /tmp/
    > test.html
    >
    >
    >
    >
    >
    >
    >
    >
    >
    192.168.0.1
    192.168.0.2

    >
    >


    sed '/$/bf;b;:f;N;s/\n//' corksite > corksite2

    produces no change.

  8. Re: Help with report gen. awk/sed

    On May 30, 8:49*am, David.LPo...@gmail.com wrote:
    > sed '/$/bf;b;:f;N;s/\n//' corksite > corksite2
    >
    > produces no change.


    It'd help if you supply the contents of "corksite" (or a meaningful
    extract of it).

  9. Re: Help with report gen. awk/sed

    On May 30, 1:49 pm, David.LPo...@gmail.com wrote:
    >
    > sed '/$/bf;b;:f;N;s/\n//' corksite > corksite2
    >
    > produces no change.


    I have:

    tcv@rose:~ $ cat corksite
    blah...
    blah...

    wooo wooo
    blah...
    blah...
    tcv@rose:~ $ sed '/$/bf;b;:f;N;s/\n//' corksite
    > corksite2

    tcv@rose:~ $ cat corksite2
    blah...
    blah...
    wooo wooo
    blah...
    blah...

    Perhaps some space is messing it up, or maybe DOS line endings?

    Try taking the dollar (line end) sign out. Also, the conditionals
    don't do anything. This reduces my code to shakah's.

    viza

+ Reply to Thread