csplit [man page] - split a file into sections determined by context lines


csplit [OPTION]... FILE PATTERN... 

Frequently used options

-f, --prefix=PREFIX
use PREFIX instead of `xx'
-k, --keep-files
do not remove output files on errors
-s, --quiet, --silent
do not print counts of output file sizes


Lets create sample file:

echo "This project's objective is not to compete with
The Linux Documentation Project , but to serve as a free
exchange reference guide for both new and established
Linux users. Visitors are encouraged to not only use the
information that is presented on this website, but to
also share any additional information that they feel will
assist other viewers. It's main purpose is to provide
viewers of all levels access to informative methods on
how to configure the Linux Operating System without having
to read large amounts of documentation." > commands.txt

Split file up to 10 parts each with one line:

csplit -k -s commands.txt 1 {10} 

Split file up to 10 parts
Do the same as above but with a prefix option:

csplit -k -s commands.txt 1 {10} 

Split file up to 10 parts with prefix

Please refer all article related questions to:

You may also be interested in: