[Somewhat OT] Getting the middle part of a file.
Hey all, This is a bit OT, but not so OT as to go to the OT list IMHO :) System is SuSE8.2 What I am trying to do: I have a large number of html files that have a segment in them I would like to copy out and save to another file. The segment I want is after a unique table tag [unique in that whilst there are other table tags, there are none like this one, and it is the same in each file]. I want to capture up until the closing table tag. ALSO I am trying to make sure that the first 4 lines [if you include the table tag] and the last 4 lines [if you include the closing tag] don't get copied to the file :) I don't ask for much, do I? ;) What I have discovered so far: I can use: grep -i "table tag stuff goes here" to get the first line, without case mattering [which isn't essential as I think they are all exactly the same, but just in case...]. I can even: grep -iA 10 "table tag stuff goes here" to get the 10 lines of output including the matching line. I can use -B instead to get the 10 lines preceding the table tag at the end, if it is unique [which the closing tag isn't]. Anyone have any good 1 or 2 liners that would help me out here? Or maybe something a bit longer :) Thanks for reading this :)
Op donderdag 18 september 2003 15:03, schreef The Purple Tiger:
grep -i "table tag stuff goes here"
to get the first line, without case mattering [which isn't essential as I think they are all exactly the same, but just in case...]. I can even: grep -iA 10 "table tag stuff goes here"
to get the 10 lines of output including the matching line.
I can use -B instead to get the 10 lines preceding the table tag at the end, if it is unique [which the closing tag isn't].
Anyone have any good 1 or 2 liners that would help me out here? Or maybe something a bit longer :)
Get cgrep which has the option -w and +w. This allows you to search for a window, which is what you want. cgrep -w "</table>" "your searchstr hear" <your files> You can get using apt or directory from: ftp://ftp.gwdg.de/pub/linux/suse/apt/SuSE/8.2-i386/RPMS.extra -- Richard Bos Without a home the journey is endless
On Thursday 18 September 2003 20:03, Richard Bos wrote:
Get cgrep which has the option -w and +w. This allows you to search for a window, which is what you want. Thank you Richard :) I will look into that *nods*
I also appreciate the link you gave :)))) Jon
The Purple Tiger wrote:
Hey all, This is a bit OT, but not so OT as to go to the OT list IMHO :)
System is SuSE8.2
What I am trying to do: I have a large number of html files that have a segment in them I would like to copy out and save to another file.
The segment I want is after a unique table tag [unique in that whilst there are other table tags, there are none like this one, and it is the same in each file]. I want to capture up until the closing table tag.
ALSO I am trying to make sure that the first 4 lines [if you include the table tag] and the last 4 lines [if you include the closing tag] don't get copied to the file :)
I don't ask for much, do I? ;)
You should can use a Perl script to do this. If you don't know Perl, send me the exact details of what you want to do and I'll see if I can make/adapt a Perl script I have, assuming the problem isn't all that hard. -- JDL Non enim propter gloriam, diuicias aut honores pugnamus set propter libertatem solummodo quam Nemo bonus nisi simul cum vita amittit.
participants (3)
-
John Lamb
-
Richard Bos
-
The Purple Tiger