LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-08-2005, 10:10 AM   #1
bomix
LQ Newbie
 
Registered: Mar 2005
Location: Denmark
Distribution: Fedora Core 4 64bit
Posts: 22

Rep: Reputation: 15
How do I cut out a specific piece of a html page (using sed/awk or similar)?


I need to cut a specific table out of a html page. How can I do that?
I've been looking at the sed and awk/gawk commands, but it's a little overwhelming for a first-time user of those commands...

It doesn't need to be done with either sed or awk. If you know some other command that can do this easily, please let me know!

Let me explain in more detail what I nedd to do:

Take a html page like this:
Code:
<html>
<body>
  ... some html stuff ...
  <table ...>
    <tr>
      <td>...</td>
    </tr>
  </table>
  ... more html stuff ...
</body>
</html>
How do I cut out the part from "<table ...>" to "</table>" ?
 
Old 10-08-2005, 03:55 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
This example might get you started....
Code:
sed '/<table.*>/,/<\/table>/d' index.html >file.txt

Last edited by homey; 10-08-2005 at 09:18 PM.
 
Old 10-08-2005, 04:30 PM   #3
bomix
LQ Newbie
 
Registered: Mar 2005
Location: Denmark
Distribution: Fedora Core 4 64bit
Posts: 22

Original Poster
Rep: Reputation: 15
Since my original post, I have started wondering if I should do what I want do in a python script. It might turn out to be easier at the end of the day.
Thanks anyway though. Even if I end up not using your contribution anyway
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
split files using awk (or similar) lgualteri Programming 1 06-13-2005 09:17 AM
How to cut a piece of my partition? don_dimo Linux - Hardware 2 05-30-2005 10:13 AM
awk/sed help pantera Programming 1 05-13-2004 11:59 PM
Does anything similar to Apple's Final Cut Pro exist for Linux? lorengd Linux - Software 11 02-09-2004 12:36 PM
cut / awk command?? Sammy2ooo Linux - Newbie 1 05-27-2003 05:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration