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 ...
-
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
-
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
-
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.
Similar Threads
-
By Application Development in forum RUBY
Replies: 2
Last Post: 10-22-2007, 08:24 AM
-
By Application Development in forum Perl
Replies: 16
Last Post: 10-19-2007, 10:20 PM
-
By Application Development in forum Python
Replies: 5
Last Post: 06-19-2007, 07:19 PM
-
By Application Development in forum Perl
Replies: 14
Last Post: 04-21-2007, 05:03 AM
-
By Application Development in forum ADO DAO RDO RDS
Replies: 0
Last Post: 11-13-2006, 04:22 PM