[glug-t] One Day One GNU/Linux Command (CSPLIT)

One Day One GNU/Linux Command
=============================

csplit - Split a file into sections determined by Context

Summary: 

Output pieces of FILE separated by PATTERN(s) to files `xx01', 
`xx02',.., and output byte counts of each piece to display. 
PATTERN(s) are Line Number or Regexp.

Examples:

$ csplit myfile 10 40 80 -- 1st file contains 1-9 lines, 2nd 10-39,
                            3rd 40-79 and 4th 80-EOF.

$ csplit myfile 10 10 80 -- Zero length file will be create for the 
                            2nd parameter..

$ csplit -z myfile 10 10 60 -- Same as above. But Zero length file 
                               will NOT created

$ csplit myfile /Midas/ -- Copy upto, but not the matching line and 
                           remaining in 2nd file.

$ csplit myfile /Midas/+6 -- Copy upto the matching line + 5 and 
                             remaining in 2nd file.

$ csplit myfile /Midas/-6 -- Copy upto the matching line - 6 and 
                             remaining in 2nd file.

$ csplit myfile /Midas/ {3} -- Repeat the previous pattern for 3 
                               more times.

$ csplit myfile /Midas/ {*} -- Repeat the previous pattern as many 
                               times as possible.

$ csplit myfile %Midas% -- skip upto, but not the matching line.

Read: man csplit

Bye :)
-- 
Bharathi S


---------------------------------------------------------------
To unsubscribe send a mail to glug_t-request@xxxxxxxxxxxxx with 
'unsubscribe' as subject.

Website: http://glugt.linuxisle.com

Other related posts: