Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 10-08-2005, 10:10 AM   #1
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:
  ... some html stuff ...
  <table ...>
  ... more html stuff ...
How do I cut out the part from "<table ...>" to "</table>" ?
Old 10-08-2005, 03:55 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 58
This example might get you started....
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
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

All times are GMT -5. The time now is 04:38 PM.

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