Re: Cut (change in question)



On Nov 30, 9:57 am, Ed Morton <mor...@xxxxxxxxxxxxxx> wrote:
On 11/29/2007 10:44 PM, sant...@xxxxxxxxx wrote:



On Nov 29, 8:49 am, Ed Morton <mor...@xxxxxxxxxxxxxx> wrote:

On 11/28/2007 12:23 AM, sant...@xxxxxxxxx wrote:

Sorry I have posted this before but I have a slight change in the
question.

I have an html file.The entire script is in one line only. The
following is the script.

<table><tbody><tr><td class="r">Chapter
1: ................................................. </td></tr></
tbody></table><p Hare Krishna ......................</p> <p Hare
Rama ......................</p>

where .............. is a variable text

In the above script I want to delete the text

<table><tbody><tr><td class="r">Chapter
1: ................................................. </td></tr></
tbody></table>

where ........ represents variable content.

I have 100 files with names 1.htm to 100.htm

How can i do this using unix commands rather than selecting the text
and deleting.

Depending on whether not "<table>" or "</table>" can occur multiple times on a
line, this may be all you need:

for file in *.htm
do
sed 's:<table>.*</table>::' "$file" > tmp &&
mv tmp "$file"
done

Regards,

Ed.

"<table>" or "</table>" can occur multiple times on a line then what
can be done

Use all of the unique text you mentioned and replace the chain of periods with ".*":

sed 's:<table><tbody><tr><td class="r">Chapter 1:.*</td></tr></tbody></table>::'

If the text on either side of the ".*" can appear elsewhere on the same line,
then it's a harder problem that needs a different approach.

Ed.

Thank you.
.



Relevant Pages

  • Re: Cut (change in question)
    ... following is the script. ... and deleting. ... for file in *.htm ... mv tmp "$file" ...
    (comp.unix.shell)
  • Re: Cut (change in question)
    ... following is the script. ... and deleting. ... for file in *.htm ... mv tmp "$file" ...
    (comp.unix.shell)
  • Re: program to copy files - problems - unix ksh to java
    ... > copying. ... sounds like the first process, when finished, deletes the file, ... I expected the script to wait for the copy to finish before ... > deleting, but it appears that it is not doing that. ...
    (comp.lang.java.programmer)
  • Re: What is wrong with this script ??
    ... I'm going to not CC beginners@xxxxxxxx after this point since I don't think this is a perl question right now. ... I manually made a directory in my system for testing the commands when I my perl script could not do for the same purpose. ... # mkdir tmp ...
    (perl.beginners)
  • Re: ruby tk -- how do you get it working?
    ... temporary location rather than deleting them directly. ... Maybe that's overly paranoid but having a script delete something ... One problem I see with that is: if your original ruby install failed to ...
    (comp.lang.ruby)