Skip to content

Instantly share code, notes, and snippets.

@itoche
Last active January 5, 2019 11:40
Show Gist options
  • Save itoche/3985c51e8ae23a49d072f325eb7672d2 to your computer and use it in GitHub Desktop.
Save itoche/3985c51e8ae23a49d072f325eb7672d2 to your computer and use it in GitHub Desktop.
Split each TXT file contained in a directory into chunks of a maximum size (here 5k)
#!/bin/bash
directory=INSERT INPUT DIRECTORY HERE
output=INSERT OUTPOUT DIRECTORY HERE
mkdir $output
find $directory -type f -name '*.txt' -exec basename {} \; | while read file;
do
split -b 5k "$directory"/"$file" "$output"/"$file".
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment