Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed , awk to copy file from line starting with 'XXX' 1

Status
Not open for further replies.

cbsm

Programmer
Oct 3, 2002
229
FR
Hello,

I am not very familiar with unix. I need to copy from file A to file B, everything between line reading 'Title XXX'
to line reading 'End XXX'.
(or if it is easier from line 'Title XXX' to the end).
file A :
AAAA
BBBB
Title XXX
CCCC
DDDD
End XXX
EEEE
I need file B:
Title XXX
CCCC
DDDD

Or
Title XXX
CCCC
DDDD
End XXX
Or

Title XXX
CCCC
DDDD
End XXX
EEEE

(I've seen solution with awk or sed - but with line numbers, that I do not have).

Thank you,
 
Sorry - just found a similar thread.
I'll try it out ...
 
OK ... didn't go very far ...
I tried this :
nawk '/RapproStkMat/{sub(/.*Title XXX/,"Title XXX");sub(/\(END XXX.*/,"");print;exit}' file.txt > NewFile.txt

* awk didn't work at all, so I tried Nawk
* result : in NewFile.txt
Title XXX
=> I miss all the lines betwenn Title XXX and END XXX....
 
awk '/Title XXX/,/End XXX/' file.txt > NewFile.txt

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top