Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Filesize limit (MiB)
- limit=$(($1 * 1000**2))
- shift
- # Accept multiple files in the arguments
- for file in $@
- do
- # Skip arguments that aren't regular files
- if [ ! -f $file ]
- then
- echo Skipping $file
- continue
- fi
- # File counts
- size=$(ls -l $file | awk '{ print $5 }')
- lines=$(wc -l $file | awk '{ print $1 }')
- parts=$((1 + $size/$limit))
- linelimit=$((1 + $lines/$parts))
- echo $file $parts parts $linelimit lines per part
- split -l $linelimit $file "$file."
- done
Add Comment
Please, Sign In to add comment