On 4/17/06, Scott Granneman <[EMAIL PROTECTED]> wrote:
> could one of you guys smarter than me help alan out? he's using a mac, btw.
I wouldn't say I was smarter than you; I have just been bedeviled by
Awk and Sed numerous times.
>
> ---------- Forwarded message ----------
> From: Alan German <[EMAIL PROTECTED]>
> Date: Apr 17, 2006 10:48 AM
> Subject: SED (or other) command help
> To: Scott Granneman <[EMAIL PROTECTED]>
>
>
> Scott,
>
> Given a file, similar to
>
> <html>
> <head>
> stuff
> </head>
> <body>
> <pre>
> content of interest
> </pre>
> </body>
> </html>
>
Here is what I got for a script, using Awk.
Save this as StripPreBlock.awk:
BEGIN { FS="\n"
RS="<"
}
{
if ($1 ~ /pre>/ && $1 !~ /\/pre>/)
{
print "<pre>"
for (j=2; j <= NF; j++)
print $j
print "</pre>"
}
}
Then if my html file is named PreTest.html and it contains stuff like this:
$ cat PreTest.html
<html>
<head>
stuff
more stuff
</head>
<body>
even more stuff
even more stuff
<pre>
content of interest
</pre>
even more stuff
even more stuff
even more stuff
</body>
</html>
then the Awk script, StripPreBlock.awk, gives this:
$ awk -f StripPreBlock.awk PreTest.html
<pre>
content of interest
</pre>
Notice the white space between content of interest and the closing
tag. I cannot get rid of that. Hey it's a hack and I am sure Robert,
Ed, or JT could do much better.
--
Kind regards,
Jonathan
_______________________________________________
CWE-LUG mailing list
[email protected]
http://www.cwelug.org/
http://www.cwelug.org/archives/
http://www.cwelug.org/mailinglist/