Skip to main content
1 of 4
danone
  • 304
  • 1
  • 3
  • 14

split file which contains 10000 lines into 30 different file

I want to split sourcefile.txt which contains 10000 lines, (increasing everyday) into 30 equal file. I have folders called /prog1/ to /prog30/ I would like to save split files into these folders with a same filename. For example /prog1/myfile.txt /prog2/myfile.txt to /prog30/myfile.txt I search but it couldn't find near my question. Thank you.

script runs in /prog/ folder called divide.sh

My bash script is below

#!/bin/bash
programpath=/home/mywebsite/project/a1/
array=/prog1/

totalline=$(wc -l < ./sourcefile.txt)

divide="$(( $totalline / 30 ))"

split --lines=$divide $./prog1/myfile.txt

 exit 1
fi
danone
  • 304
  • 1
  • 3
  • 14