LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-07-2009, 03:34 PM   #1
austin881
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
KSH Output/Strip portion of file in HP-UX


I have a file, we'll call it file.txt. It has thousands of lines of all kinds of output at any given time (ie. foo bar foo bar)

I need to copy out just a portion of the file from Point-A to Point-B. I'd like to save off just that portion to a file called test123xyz.txt.

How do I do that?


Code:
1. foo
2. bar
3. foo
4. bar
5. <<<BEGIN test123xyz (<--Point-A)
6. foo
7. bar
8. foo
9. bar
~
~
~
~
~
~
991. foo
992. bar
993. foo
994. bar
995. >>>END test123xyz (<--Point-B)
996. foo
997. bar
998. foo
Now the good thing is, there are markers where I need to make the copy happen (ie. <<<BEGIN test123xyz)

I'm sure this is a simple grep, sed, awk or something that I can do but I've tried everything I know of with no success. Any ideas?

HP-UX 11.31, korn shell scripting.
 
Old 10-07-2009, 08:25 PM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
This homework assignment has been done a few times here on the board. Have you tried searching?
 
Old 10-08-2009, 01:53 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
A google of 'sed pattern range extract' found the answer on the page of results ... GIYF
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
grep only certain portion of the file packets Programming 5 06-10-2009 12:20 AM
How to strip a specific part of text from a larger file? pepsi_max2k Programming 10 03-27-2009 05:00 AM
how to use grep and tail to get portion of a file laurasong Linux - General 7 08-20-2007 12:59 AM
Strip comments from a file introuble Programming 9 10-02-2006 05:05 PM
Only load last portion of a file, instead of the whole really big text file 1veedo Linux - General 2 02-20-2006 07:34 PM


All times are GMT -5. The time now is 03:11 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration