Open In App

csplit command in Linux with examples

The csplit command is used to split any file into many parts as required by the user. The parts are determined by context lines. Output 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…

Example: Consider a text file named list.txt with contents as follows:



Now split this file into two parts (second part starting from 3rd line) using csplit command as follows:

Options:

Article Tags :