Ubuntu 24.04
Sponsored Link

Command Help

Command :   Back to index

csplit : split a file into sections determined by context lines
[SYNOPSIS] csplit OPTION FILE PATTERN
PATTERN
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
OPTION
-b FORMAT use sprintf FORMAT instead of %02d
-f PREFIX use PREFIX instead of 'xx'
-k do not remove output files on errors
-n DIGITS use specified number of digits instead of 2
-s do not print counts of output file sizes
-z suppress empty output files
 Usage example :
 [root@localhost ~]# cat testfile.txt
 testfile1
 testfile1 testfile1
 
 testfile2 testfile2
 testfile2
 
 testfile3 testfile3 testfile3
 testfile3 testfile3
 
 [root@localhost ~]# csplit -s -n 3 -f testfile.txt testfile.txt '/^$/' {*}
 
 [root@localhost ~]# ls -l
 total 20
 -rw-------. 1 root root 1024 Sep 19  2022 anaconda-ks.cfg
 -rw-r--r--. 1 root root  112 Nov 17 15:33 testfile.txt
 -rw-r--r--. 1 root root   30 Nov 17 15:47 testfile.txt000
 -rw-r--r--. 1 root root   31 Nov 17 15:47 testfile.txt001
 -rw-r--r--. 1 root root   51 Nov 17 15:47 testfile.txt002
 
 [root@localhost ~]# cat testfile.txt000
 testfile1
 testfile1 testfile1
 
 [root@localhost ~]# cat testfile.txt001
 
 testfile2 testfile2
 testfile2
 
 [root@localhost ~]# cat testfile.txt002
 
 testfile3 testfile3 testfile3
 testfile3 testfile3
 

मिलान सामग्री