#!/bin/bash
# assuming the file is in the same folder as the script
INPUT=large_file.txt
# assuming the folder called "output" is in the same folder
# as the script and there are folders that have the patter
# prog01 prog02 ... prog30
# create that with mkdir output/prog{01..30}
OUTPUT_FOLDER=output
OUTPUT_FILE_FORMAT=myfile
# split
# -n -> 30 files
# $OUTPUT_FILE_FORMAT -> should start with this pattern
# --numeric-suffixes=1 -> end of file name should start from 01
split -n 30 $INPUT $OUTPUT_FILE_FORMAT --numeric-suffixes=1
# move all files to their repective directories
for i in {01..30}
do
mv $OUTPUT_FILE_FORMAT$i $OUTPUT_FOLDER/prog$i/myfile.txt
done
echo "done :)"
exit
The split command is more than enough for this task. However the solution here requires you to make your folder names start from prog01
and not prog1