The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-13-2008
Migrainegirl Migrainegirl is offline
Registered User
  
 

Join Date: May 2008
Posts: 3
split files into specified number of output files

Hi everyone,

I have some large text files that I need to split into a specific number of files of equal size. As far as I know (and I don't really know that much ) the split command only lets you specify the number of lines or bytes. The files are all of a different size, so the number of lines differ as well.
I use the following code to see how many lines each output file should be (1/50 of the original document):

y=`wc | awk '{ print $x/50}' | awk -F. '{if($2>=1){print $1+1}else{print $1}}'`
echo $y

The problem is that I can't use this variable $y as input for the split command like this:

split $x -d -l $y split/$x

It simply doesn't work. Does anyone know a way to pass the value of the $y variable into the split command? Or does anyone have a better way of solving the entire problem?

Thanks in advance!