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

Re: Dividing a large long lined file



Marcelo Ramos wrote:
  >On Wed, Sep 01, 1999 at 06:40:42PM -0700, John Haggerty wrote:
  >> I thought I would ask this question since it is about general unix and deb
      >ian as well.
  >> I have a file which is say about 700 characters wide and 2,000 characters 
      >long I wish to take this file and divide this into equal files horizonta
      >lly AND vertically say about 65 characters long and 80 wide. I tried to 
      >look for an obvious way to do this but can only divide it into horizonta
      >l portions with split.
 
To do it vertically, use cut -c:

FILE=/path/to/file
OUTDIR=/output/directory
MAXLENGTH=700
SLICE=1
WIDTH=65
START=1
while [ $START -le $MAXLENGTH ]
do
	END=`expr $START + $WIDTH - 1`
	outf=$OUTDIR/slice$START
	cut -c$START-$END <$FILE >$outf
	START=`expr $START + $WIDTH`
done
-- 
      Vote against SPAM: http://www.politik-digital.de/spam/
                 ========================================
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "But God said to him, You fool! This very night your
      soul is required of you; and now who will own what you
      have prepared? So is the man who lays up treasure for
      himself, and is not rich toward God."           
                                        Luke 12:20,21 



Reply to: