Csplit

Csplit


Linux csplit command

  • On Unix-like operating systems, the csplit command splits a file into sections, based on context lines.

  • This document covers the GNU/Linux version of ucsplit.

    Description

  • csplit outputs pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output.

    Syntax

    csplit OPTION... FILE PATTERN...
    Options

  • -b, --suffix-format=FORMAT use sprintf FORMAT instead of %02d.

  • -f, --prefix=PREFIX use PREFIX instead of 'xx'.

  • -k, --keep-files do not remove output files on errors.

  • -n, --digits=DIGITS use specified number of digits instead of 2.

  • -s, --quiet, --silent do not print counts of output file sizes.

  • -z, --elide-empty-files remove empty output files.

  • --help display a help message and exit.

  • --version output version information and exit.
    csplit reads standard input if FILE is specified as a dash ("-"). Each PATTERN may be:

    INTEGER copy up to but not including specified line number.

  • /REGEXP/OFFSET copy up to but not including a matching line.

  • %REGEXP%OFFSET skip to, but not including a matching line.

  • {INTEGER} repeat the previous pattern specified number of times.

  • {*} repeat the previous pattern as many times as possible.

  • A line OFFSET is a required '+' or '-' followed by a positive integer.

    Examples

    csplit -f cobol filename '/procedure division/' /par5./ /par16./
    Creates four files, cobol00...cobol03.

  • After editing the split files, they can be recombined into filename using the cat command as follows:

    cat cobol00-3 > filename

    Related commands

  • cat — Output the contents of a file.

  • sed — A utility for filtering and transforming text.

  • split — Split a file into pieces.

    What is an Operating System? » Computer Shortcut Keys and their Functions » Keyboard Function Keys » Computer Basics - Hardware
    - Software - Parts


    Short Stories for Kids - Moral Stories – English Short Stories for Children - Moral Stories for Kids - Stories for Kids - Funny Story for Kids - Scary Stories for Kids - Really Funny Short Stories - Bedtime Stories
    Proverb Stories
    Powerful Motivational Quotes for Students » Success Quotes » English Short Stories for Kids

    Cabin Crew Jobs & Career Advice » Secretary Job Description » Receptionist Job Description » Top 100 Interview Questions and Answers » How to Prepare for an Interview » How to Write a CV » How to Choose a Career » Computer Shortcut Keys and their Functions

    Scholarships in Australia » Scholarships in Austria » Scholarships in Belgium » Scholarships in Canada » Scholarships in Germany » Scholarships in Ireland » Scholarships in Italy » Scholarships in Japan » Scholarships in Korea » Scholarships in Netherlands » Scholarships in Switzerland » Scholarships in UK » Scholarships in USA

    Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Scholarships for Study in Africa » Scholarships for African Students » Undergraduate Scholarships » African Women Scholarships & Grants Short Stories for Kids - Moral Stories – English Short Stories for Children - Moral Stories for Kids - Stories for Kids - Funny Story for Kids - Scary Stories for Kids - Really Funny Short Stories - Bedtime Stories
    Proverb Stories
    Powerful Motivational Quotes for Students » Success Quotes »Scholarships in UK » Scholarships in USA Scholarships in UK » Scholarships in USA Scholarships in UK »

  • Click here to post comments

    Join in and write your own page! It's easy to do. How? Simply click here to return to Computer Basics FAQ.