Unix Shell - Cut

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > November 2007 > Cut





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Cut
sant527@gmail.com

2007-11-27, 7:33 am

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>

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.

Thanks
Santhosh
mallin.shetland

2007-11-27, 7:33 am

sant527@gmail.com scrisse:

> ...


sed -i 's:<p Hare Krishna</p>::g' $_a_bunch_of_files

man sed

My two eurocent

PS No, I don't want dollars :D

thomasriise

2007-11-27, 7:33 am


Does it say "<p Hare Krishna</p> " in all files?
thomasriise

2007-11-27, 7:33 am

for file in `ls *.html 2>/dev/null`
do
cat $file | sed 's/\(.*\)\(<p Hare Krishna<\/p>\)\(.*\)/\2/'g >
tempfile
mv tempfile $file
done
Janis

2007-11-27, 7:33 am

On 27 Nov., 11:00, thomasriise <thomasri...@gmail.com> wrote:
> for file in `ls *.html 2>/dev/null`


for file in *.html

> do
> cat $file | sed 's/\(.*\)\(<p Hare Krishna<\/p>\)\(.*\)/\2/'g >tempfile


sed 's/.../.../g' "$file" >tempfile &&

> mv tempfile $file


mv tempfile "$file"

> done


Janis
thomasriise

2007-11-27, 7:33 am

> sed 's/.../.../g' "$file" >tempfile &&

- point taken
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com