Contents[Hide]

1. Name

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

2. Synopsis

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

3. 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

4. Examples

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 --prefix=linuxconfig.org commands.txt 1 {10} 

Split file up to 10 parts with prefix



Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top