csplit question

csplit question

Post by Ranjit » Wed, 08 Jan 2003 14:11:30



Hi,

I have a file($TEMP_FILE1) like this :

01/01/03  n flskj 090-oi98 AAAAAA LKJK
LSJFL LKDFJLS 078424MLKHL
FLSKJ LSJF9872R2J

01/01/03  n flSskj 0290-oi98 AAAAAA LSSDF2K
LSLKSFJ092JFL LKDFJLS 078424MLKHL
FLSKJ LSJFKL8783289872R2J
LKHJOWIUROW SFW2R 234

02/12/02  n flkj 0595-oi98 AAAAAA LSSDF2K
LSLKSFJ092JFL LKDFJLS 078424MLKHL
FLSKJ LSJFKL8783289872R2J
LKHJOWIUROW SFW2R 234

and so on....(there may be close to 60 paragraphs like this..)

I need to split this file such that the output files contain
one paragraph each..
I am using the following command for this..
csplit -s -k -f TEMP -n 2 $TEMP_FILE1 /"AAAAAA"/-1 '{70}' 2>&-

first line of each paragraph contains the pattern "AAAAAA".
so I need to do the splitting between two lines containing this pattern.
Problem with the following command is since the very first line
of this file matches the expression, it wont produce the required
result..can anyone help....

 
 
 

csplit question

Post by John » Wed, 08 Jan 2003 17:11:09



> Hi,

> I have a file($TEMP_FILE1) like this :

> 01/01/03  n flskj 090-oi98 AAAAAA LKJK
> LSJFL LKDFJLS 078424MLKHL
> FLSKJ LSJF9872R2J

> 01/01/03  n flSskj 0290-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> 02/12/02  n flkj 0595-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> and so on....(there may be close to 60 paragraphs like this..)

> I need to split this file such that the output files contain
> one paragraph each..
> I am using the following command for this..
> csplit -s -k -f TEMP -n 2 $TEMP_FILE1 /"AAAAAA"/-1 '{70}' 2>&-

> first line of each paragraph contains the pattern "AAAAAA".
> so I need to do the splitting between two lines containing this pattern.
> Problem with the following command is since the very first line
> of this file matches the expression, it wont produce the required
> result..can anyone help....

The trick is to csplit on the blank lines separating the paragraphs.

csplit $TEMPFILE '/^$' '{*}'

You will see I have omitted most of your arguments -- this is because
I am too lazy to type them, so by all means put them back in.
But note that I have used '{*}' (to mean as many times as possible)
rather than '{70}' (which means 70 times, of course).

John.

 
 
 

csplit question

Post by John » Wed, 08 Jan 2003 17:12:51



> The trick is to csplit on the blank lines separating the paragraphs.

> csplit $TEMPFILE '/^$' '{*}'

Oops. Left out a / -- it should be:

csplit $TEMPFILE '/^$/' '{*}'

John.

 
 
 

csplit question

Post by Juergen Hec » Thu, 09 Jan 2003 02:50:45



> Hi,

> I have a file($TEMP_FILE1) like this :

> 01/01/03  n flskj 090-oi98 AAAAAA LKJK
> LSJFL LKDFJLS 078424MLKHL
> FLSKJ LSJF9872R2J

> 01/01/03  n flSskj 0290-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> 02/12/02  n flkj 0595-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> and so on....(there may be close to 60 paragraphs like this..)

> I need to split this file such that the output files contain
> one paragraph each..
> I am using the following command for this..
> csplit -s -k -f TEMP -n 2 $TEMP_FILE1 /"AAAAAA"/-1 '{70}' 2>&-

> first line of each paragraph contains the pattern "AAAAAA".
> so I need to do the splitting between two lines containing this pattern.
> Problem with the following command is since the very first line
> of this file matches the expression, it wont produce the required
> result..can anyone help....

try

csplit -s -k -f TEMP -n 2 $TEMP_FILE1 '%AAAAAA%' '/AAAAAA/' {70} 2>&-

Regards
Juergen

 
 
 

csplit question

Post by William Par » Fri, 10 Jan 2003 05:09:20



Quote:> Hi,

> I have a file($TEMP_FILE1) like this :

> 01/01/03  n flskj 090-oi98 AAAAAA LKJK
> LSJFL LKDFJLS 078424MLKHL
> FLSKJ LSJF9872R2J

> 01/01/03  n flSskj 0290-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> 02/12/02  n flkj 0595-oi98 AAAAAA LSSDF2K
> LSLKSFJ092JFL LKDFJLS 078424MLKHL
> FLSKJ LSJFKL8783289872R2J
> LKHJOWIUROW SFW2R 234

> and so on....(there may be close to 60 paragraphs like this..)

> I need to split this file such that the output files contain
> one paragraph each..
> I am using the following command for this..
> csplit -s -k -f TEMP -n 2 $TEMP_FILE1 /"AAAAAA"/-1 '{70}' 2>&-

> first line of each paragraph contains the pattern "AAAAAA".
> so I need to do the splitting between two lines containing this pattern.
> Problem with the following command is since the very first line
> of this file matches the expression, it wont produce the required
> result..can anyone help....

I don't follow.  The command will give you one paragraph per file,
beginning with a blank line and then the line containing 'AAAAAA'.

--

Linux solution for data management and processing.

 
 
 

1. questions for CSPLIT?

Hi there,

I) By default, csplit divides the file into files xx00, xx01 ...

Can someone there show me to how to change the starting point from 00
to 01, i.e., the output files would start with xx01?

II) I have a command
    csplit -skz filename 4 {*}
  when the 4th line is a blank line, the file xx01 will contain 5
lines, only the first line is blank.
    Is there a way to force CSPLIT take the blank line as one line,
output 3 non-blank lines in the file, instead of 4?

Thanks,

2. Solaris 2.3 accounting problem - runacct

3. csplit problem

4. Can I run AIX Connections on AIX 4.3

5. csplit

6. Question for the Debian users out there...

7. Using csplit to split files

8. Javasoft Servlet support for Apache

9. Can csplit emulate fsplit?

10. csplit command - more than 99 splits?

11. csplit

12. using csplit (or something) in a one-line command

13. csplit file limit