Return to BSD News archive
Path: sserve!newshost.anu.edu.au!munnari.oz.au!constellation!osuunx.ucc.okstate.edu!moe.ksu.ksu.edu!crcnis1.unl.edu!wupost!howland.reston.ans.net!pipex!uunet!destroyer!news.itd.umich.edu!honey From: honey@citi.umich.edu (Peter Honeyman) Newsgroups: comp.unix.bsd Subject: Re: splitting a one line file Date: 6 Oct 1993 02:20:12 GMT Organization: Center for Information Technology Integration, Univ of Michigan Lines: 18 Distribution: world Message-ID: <28ta0s$bma@terminator.rs.itd.umich.edu> References: <28si9m$ed6@male.EBay.Sun.COM> Reply-To: honey@citi.umich.edu NNTP-Posting-Host: 141.211.170.43 give this a try. peter #!/bin/sh case $# in 2) bs=1 count=$2;; 1) bs=4 count=16;; *) echo "usage: msplit infile [outsize in kbytes, default is 64]" 1>&2 exit 1;; esac unit=`expr $bs '*' $count '*' 1024` rem=`ls -l $1|awk '{printf $4}'` num=100 skip=0 while [ $rem -gt 0 ]; do dd bs=${bs}k count=$count skip=$skip if=$1 of=$1.$num rem=`expr $rem - $unit` skip=`expr $skip + $count` num=`expr $num + 1` done