Split: how to split into different percentages split How can I split a text file into 70% and 30% using the split command ? Best Answer The commands below will work for percentages above 50% (if you want to split only into two files), quick and dirty approach. 1) split 70% based on lines split -l $[ $(wc -l filename|cut -d" " -f1) * 70 / 100 ] filename 2) split 70% based on bytes split -b $[ $(wc -c filename|cut -d" " -f1) * 70 / 100 ] filename Related SolutionsHow to split a large text file into chunks of 500 words or so Must it be done with wc? Because here I've ran into a very nice attempt to use regex as a csplit pattern. I don't have a system to test it right now but the regex itself seem to do the job. The expression looks like that: csplit input-file.txt '/([\w.,;]+\s+){500}/' Scripting PDF – How to Split PDF into Documents with Several Pages Each pdftk is able to cut out a fixed set of pages efficiently. With a bit of scripting glue, this does what I want: number=$(pdfinfo -- "$file" 2> /dev/null | awk '$1 == "Pages:" {print $2}') count=$((number / pagesper)) filename=${file%.pdf} counter=0 while [ "$count" -gt "$counter" ]; do start=$((counter*pagesper + 1)); end=$((start + pagesper - 1)); counterstring=$(printf %04d "$counter") pdftk "$file" cat "${start}-${end}" output "${filename}_${counterstring}.pdf" counter=$((counter + 1)) done This assumes that you have the number of pages per chunk in $pagesper and the filename of the source PDF in $file. If you have acroread installed, you can also use acroread -size a4 -start "$start" -end "$end" -pairs "$file" "${filename}_${counterstring}.ps" acroread offers the option -toPostScript which may be useful. Related QuestionHow to Split Text Between Separator into Multiple FilesSplit text file into lines with fixed number of words
Best Answer
The commands below will work for percentages above 50% (if you want to split only into two files), quick and dirty approach.
1) split 70% based on lines
2) split 70% based on bytes