Guest User

Untitled

a guest
Jan 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Filesize limit (MiB)
  4. limit=$(($1 * 1000**2))
  5. shift
  6.  
  7. # Accept multiple files in the arguments
  8. for file in $@
  9. do
  10. # Skip arguments that aren't regular files
  11. if [ ! -f $file ]
  12. then
  13. echo Skipping $file
  14. continue
  15. fi
  16.  
  17. # File counts
  18. size=$(ls -l $file | awk '{ print $5 }')
  19. lines=$(wc -l $file | awk '{ print $1 }')
  20. parts=$((1 + $size/$limit))
  21. linelimit=$((1 + $lines/$parts))
  22.  
  23. echo $file $parts parts $linelimit lines per part
  24. split -l $linelimit $file "$file."
  25. done
Add Comment
Please, Sign In to add comment