remove large portion of web page code between two tags


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove large portion of web page code between two tags
# 1  
Old 04-29-2012
remove large portion of web page code between two tags

Hi everybody,

I am trying to remove bunch of lines from web pages between two tags:
one is <h1> and the other is <table

it looks like

Code:
<h1>Anniversary cards roses</h1>
many
lines here
<table summary="Free anniversary greeting cards." cellspacing="8" cellpadding="8" width="70%">

my goal is to delete all including <h1> but keep untouched

Code:
<table summary="Free anniversary greeting cards" cellspacing="8" cellpadding="8" width="70%">

any help is greatly appreciated.
# 2  
Old 04-29-2012
Code:
perl -lp0e 's/<h1>.*<table/<table/s' infile > outfile

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 04-29-2012
Code:
awk 'BEGIN{ok=1}
       /^<h1>/ {ok=0}
       /<^table summary="Free anniversary greeting cards" cellspacing="8" cellpadding="8" width="70%"> {ok=1}
      ok==1 {print}
      ok==0 {next} '   inputfile > outputfile

This clobbers everything including the FIRST <hl> tag onward. It stops clobbering at the exact table summary statement you gave.
This User Gave Thanks to jim mcnamara For This Post:
# 4  
Old 04-29-2012
command works

bartus11, your command works great.

Code:
perl -lp0e 's/<h1>.*<table/<table/s' infile > outfile

but, would please advise how to make all changes in place and create backup file.

thank you very much.

jim, when i ran your code it came up with an error message

Code:
awk: cmd. line:3:  ^ unterminated regexp

but i also thank you for your time and effort.
# 5  
Old 04-29-2012
Code:
perl -i.bak -lp0e 's/<h1>.*<table/<table/s' infile

This User Gave Thanks to bartus11 For This Post:
# 6  
Old 04-29-2012
thank you

thank you again.

really appreciate it
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

Loading Animation for Large Man Page Repositories

Should have done this 10 years ago, so better late than never: Just added a "loading" animation to the the man page repositories when they load, especially since some are very large and take many seconds to load. See for example: https://www.unix.com/man-page-opensolaris-repository.php ... (1 Reply)
Discussion started by: Neo
1 Replies

2. UNIX for Dummies Questions & Answers

Remove the date portion from file name

hi, I am trying to remove the last field before the period (.) from a list of file names in a directory in a shell script. Below is the list of file names. ENVID_archival_20120214092258.log ENVID_Get_Source_Files_20120214091828.log ENVID_Get_Source_Files_20120214092523.log... (6 Replies)
Discussion started by: Vijay81
6 Replies

3. Shell Programming and Scripting

Page Break in large file

Hi, The shell script inserting the millions of rows into target flat file system and handling the line number for each line. We need a page break line after every 10,000 lines. is there any command to insert a page break line into target file. (3 Replies)
Discussion started by: koti_rama
3 Replies

4. Shell Programming and Scripting

Remove first portion of string

I have a script which currently uses a file containing a list of directories as an argument. The file is read in to an array, and then the array is iterated in a for loop. What I would like to do is cut off the first few directories of the directory path (they won't exist on the server where the... (5 Replies)
Discussion started by: msarro
5 Replies

5. Shell Programming and Scripting

Extracting a portion of data from a very large tab delimited text file

Hi All I wanted to know how to effectively delete some columns in a large tab delimited file. I have a file that contains 5 columns and almost 100,000 rows 3456 f g t t 3456 g h 456 f h 4567 f g h z 345 f g 567 h j k lThis is a very large data file and tab delimited. I need... (2 Replies)
Discussion started by: Lucky Ali
2 Replies

6. AIX

amount of memory allocated to large page

We just set up a system to use large pages. I want to know if there is a command to see how much of the memory is being used for large pages. For example if we have a system with 8GB of RAm assigned and it has been set to use 4GB for large pages is there a command to show that 4GB of the *GB is... (1 Reply)
Discussion started by: daveisme
1 Replies

7. Solaris

Page cache too large

I have a solaris10 box running a java application on it. Whenever the java app is used heavily, the amount of free memory decreases fairly rapidly. I believe I have eliminated the running applications from the culprit list. In the process I have found that the page cache is consuming about 20G... (4 Replies)
Discussion started by: timothy.edwards
4 Replies

8. UNIX for Dummies Questions & Answers

Which comand to show the source code on a web page?

Hi folks! I am using MacOsX that runs freeBSD. Could you tell me what comand to type on the Unix Terminal to display on the terminal the source code of a certain web page? I think something like #<comand> http://www.apple.com will display on the terminal's window the html source code... (11 Replies)
Discussion started by: fundidor
11 Replies

9. Shell Programming and Scripting

remove portion of file

Can anyone tell me how to remove a portion of a large file to smaller ones? What I have is a large file that was created becasue several similar files were joined together. Each individual file starts with MSG_HEAD. I want to take everything from MSG_HEAD up to were it says MSG_HEAD again and... (13 Replies)
Discussion started by: methos
13 Replies

10. UNIX for Dummies Questions & Answers

Web page hosting

I built my website based on Dreamweaver, on Windows platform. My server uses Unix, and the page doesn't look too good. Is there any way to solve this problem without too much of a headache? (1 Reply)
Discussion started by: PCL
1 Replies
Login or Register to Ask a Question