Csplit


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

csplit - split a file into sections determined by context lines

Synopsis - man page

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

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 part each with one line:

csplit -k -s commands.txt 1 {10}
Image:csplit01.gif

Do the same as above but with a prefix option:

csplit -k -s --prefix=linuxconfig.org commands.txt 1 {10}
Image:csplit02.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands