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

Split one file into seperate files 1

Status
Not open for further replies.

rneve

MIS
Oct 11, 2002
51
0
0
EU
Hi,

I'm looking for a script the can split a file (example below) into seperate file. The parts that should be in the seperate files are the lines between the "----" lines.
I don't know how to do that... Any suggestions?

Thanks in advance.

Sample file:

---------------------------------------------------------------------------
LABEL: CONSOLE
IDENTIFIER: 7F88E76D

Date/Time: Sun Mar 9 09:28:21 NFT 2008
Sequence Number: 19759
Machine Id: 00C4DA704C00
Node Id: nlchv3xmn001
Class: S
Type: PERM
Resource Name: console

Description
SOFTWARE PROGRAM ERROR
---------------------------------------------------------------------------
LABEL: CONSOLE
IDENTIFIER: 7F88E76D

Date/Time: Sun Mar 9 09:28:21 NFT 2008
Sequence Number: 19759
Machine Id: 00C4DA704C00
Node Id: nlchv3xmn001
Class: S
Type: PERM
Resource Name: console

Description
SOFTWARE PROGRAM ERROR
---------------------------------------------------------------------------
 
split -n14

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Or, if the records have variable lengths:

Code:
awk -v n=0 '
        /^---/ { close("file" n++) ; next }
        { print >> "file" n }
' inputfile

Will create file1, file2, file3 ....

Annihilannic.
 
Thanks.. This is what I was looking for!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top