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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to split a file based on content 1

Status
Not open for further replies.

ls62

Programmer
Oct 15, 2001
177
US
Hi,

I have a file that I want to split into multiple files based upon the content. I want to split the file wherever the line begins with "ISA" as the first 3 characters.

I thought I could use "csplit flat.txt '/^ISA/'", but it doesn't work. Am I missing something or is this the wrong command.

Heres a sample of what my data might look like:

---
ISA*A
ALINE1
ALINE2
ISA-B
BLINE1
BLINE2
ISA^C
CLINE1
---

I should get 3 files

Thanks for any help.
LEE
 
Either this:
csplit -s -k flat.txt '/^ISA/' {99}
Or this:
man awk

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH,

Thanks, that did it. Now that it works I understand that the {99} was needed to cause the regexp to be repeated.

Thanks again!

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top