[comp.sys.sgi] Problem with csplit .....

finn.drablos@sintef.no (Finn Drablos) (10/01/90)

I have a source code file with several subroutines. Each subroutine is
started with a comment line with 'BEGIN <name-of-routine>'.

Now I want to split this into separate files with csplit, and as I
understand the man page the following command should work :

csplit -k source.src /BEGIN/ {40}

However, it seems to split up to the first BEGIN, and then the next 40
lines. It does not use the pattern 40 times. I have tried /BEGIN/{40},
'/BEGIN/ {40}', '/BEGIN/{40}', '/BEGIN/+0 {40}', '/BEGIN/+0{40}',
'/BEGIN/'{40} etc. ...

Am I doing something obviously wrong, or is there a problem with csplit?
I am using csh and IRIX 3.2.1.

Thanks in advance!

==================

Finn Drablos                 PHONE +47 7 997710       FAX +47 7 997708
MR-Senteret, UNIMED, SINTEF  C=no;P=uninett;O=sintef;G=finn;S=drablos;
N-7034 TRONDHEIM, NORWAY     MHS(EAN)    : finn.drablos@sintef.no 
                             EARN/BITNET : drabloes@norunit
----------------------------------------------------------------------

davea@quasar.wpd.sgi.com (David B.Anderson) (10/02/90)

In article <218*finn.drablos@sintef.no> finn.drablos@sintef.no (Finn Drablos) writes:
[stuff deleted]
>csplit -k source.src /BEGIN/ {40}
[stuff deleted]
>lines. It does not use the pattern 40 times. I have tried /BEGIN/{40},

csh strips the {}.   Use:
	  csplit -k source.src /BEGIN/ \{40\}

Regards,
[ David B. Anderson  Silicon Graphics  (415)335-1548  davea@sgi.com ]
[``What can go wrong?''                          --Calvin and Hobbes]

pj@giraffe.asd.sgi.com (Paul Jackson) (10/02/90)

In article <218*finn.drablos@sintef.no>, finn.drablos@sintef.no (Finn Drablos) writes:
|> I have a source code file with several subroutines. Each subroutine is
|> started with a comment line with 'BEGIN <name-of-routine>'.
|> 
|> Now I want to split this into separate files with csplit, and as I
|> understand the man page the following command should work :
|> 
|> csplit -k source.src /BEGIN/ {40}
|> 
|> However, it seems to split up to the first BEGIN, and then the next 40
|> lines. It does not use the pattern 40 times. I have tried /BEGIN/{40},
|> '/BEGIN/ {40}', '/BEGIN/{40}', '/BEGIN/+0 {40}', '/BEGIN/+0{40}',
|> '/BEGIN/'{40} etc. ...

The csh strips off the unquoted { } characters, so that the actual
argument seen by csplit is a simple 40, which is taken as a line number.

Try:
	csplit -k source.src /BEGIN/ '{40}'

where the single quotes protect the { } characters.
Your other attempts mostly tried to force the /BEGIN/ and the {40}
into a single argument, which is not what you want.

-- 

				Thanks, take care ...
				Paul Jackson (pj@asd.sgi.com), x1373