bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: split, csplit or nl ?


From: Olivier Delhomme
Subject: Re: split, csplit or nl ?
Date: Tue, 8 Mar 2005 22:54:52 +0100

Le Tue, 8 Mar 2005 06:44:27 +0000 (GMT), Philip Rowlands disait :

> On Mon, 7 Mar 2005, Olivier Delhomme wrote:
> 
> >I have a specific problem with a file that i want to split :
> >I would like to split the file in 'x' pieces for exemple. But i would
> >like to have line one in file one, line two in file two and so on then
> >line x in file x and line x+1 in file one ...
> 
> sed -ne '1~2p' < input > oddlines
> sed -ne '2~2p' < input > evenlines

Thanks a lot, this is exactly what I was looking for ! I didn't expected
that sed would do the job !

what I want can be done like this :
where nbp == 'x' pieces and file == the file I want to split

nbp=8;
file=myfile.to.split;

for i in $(seq 1 $nbp); do
  echo -n "$i~$nbp" >script.file; 
  echo "p" >>script.file;
  cat $file | sed -nf script.file >$file.piece.$i
done;

> Cheers,
> Phil

Thanks again, this will save much time,

Cheers,
Olivier. 

Attachment: pgpgSc1qbSnko.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]