Printing substrings of a line ? - awk

This is a discussion on Printing substrings of a line ? - awk ; Hi, I have one or severl long lines in a file. I'd like to print out substrings in these lines, preferably each as a single line. The strings are, <a href="http...pdf"> where ... can vary. Ideally I'd get out, http...pdf ...

+ Reply to Thread
Results 1 to 3 of 3

Printing substrings of a line ?

  1. Default Printing substrings of a line ?

    Hi, I have one or severl long lines in a file.
    I'd like to print out substrings in these lines,
    preferably each as a single line. The strings are,
    <a href="http...pdf"> where ... can vary.
    Ideally I'd get out,

    http...pdf (string 1)
    http...pdf (string 2)
    ....
    http...pdf (string 3)

    Thanks for any help and tips.
    m


  2. Default Re: Printing substrings of a line ?


    Ï/Ç mmichaelz@ Ýãñáøå:
    > Hi, I have one or severl long lines in a file.
    > I'd like to print out substrings in these lines,
    > preferably each as a single line. The strings are,
    > <a href="http...pdf"> where ... can vary.
    > Ideally I'd get out,
    >
    > http...pdf (string 1)
    > http...pdf (string 2)
    > ...
    > http...pdf (string 3)
    >
    > Thanks for any help and tips.
    > m


    Try

    awk -F\" '{ gsub(/<a +href=/, ""); gsub(/>/, ""); for (i = 1; i <= NF;
    i++) if ($i) print $i }' file.html


  3. Default Re: Printing substrings of a line ?

    mmichaelz@ wrote:
    > Hi, I have one or severl long lines in a file.
    > I'd like to print out substrings in these lines,
    > preferably each as a single line. The strings are,
    > <a href="http...pdf"> where ... can vary.
    > Ideally I'd get out,
    >
    > http...pdf (string 1)
    > http...pdf (string 2)
    > ...
    > http...pdf (string 3)
    >
    > Thanks for any help and tips.
    > m
    >


    a) Can there be multiple occurences of these substrings on one line?
    b) Can the text of a substring be split across lines?
    c) Can any of the text that delimits the substrings (e.g. "<a href=")
    appear within the quoted parts (e.g. <a href="http <a href= .pdf">)?
    d) Can the quotation characters appear escaped within the quoted parts
    (e.g. <a href="this is a \" character.pdf">)

    I assume the text inside the quotes always ends in an explicit
    "<dot>pdf" rather than "<anychar>pdf".

    Regards,

    Ed.

+ Reply to Thread

Similar Threads

  1. Printing Line number during runtime
    By Application Development in forum RUBY
    Replies: 2
    Last Post: 10-22-2007, 08:24 AM
  2. printing a subject line
    By Application Development in forum Perl
    Replies: 16
    Last Post: 10-19-2007, 10:20 PM
  3. Re printing on same line.
    By Application Development in forum Python
    Replies: 5
    Last Post: 06-19-2007, 07:19 PM
  4. Printing the next line of text of the file
    By Application Development in forum Perl
    Replies: 14
    Last Post: 04-21-2007, 05:03 AM
  5. Printing of line out of a TDMmemo table
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 11-13-2006, 04:22 PM