Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the csplit command of linux to split the file

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the use of linux csplit command to split the file, has a certain reference value, friends in need can refer to. Let's take a look at it with me.

The English full name of the csplit command is "context split". This command is used to split a large file into small fragments and save each fragment into a file. Fragmented files are named like "xx00" and "xx01". The csplit command is a variant of split. Split can only split files according to file size or number of lines, but csplit can split files according to their own characteristics.

Syntax parameter: csplit [parameter]

Common parameters:

-b or-- suffix-format= preset output format whose file name is xx00,xx01, etc. Users can change the output file name-f or-- prefix= preset output header string and its file name is xx00,xx01, etc. If the output header string is set to "hello", the output file name will become hello00,hello, 01... -k or-- keep-files keeps the file, even if an error occurs or interrupts execution, and cannot delete the output file name of the saved file-n or-- digits= preset, whose file name is xx00,xx01. If the user specifies that the output file name is "3", the output file name becomes-Q or-s such as xx000,xx001 or-- quiet or-- silent does not show instruction execution process-z or-- elide-empty-files delete length is 0 Byte file.

Reference example

Cut the text file filename into two pieces at the second behavior demarcation point:

[root@linuxcool ~] # csplit filename 2

Cut the text file filename into 2 pieces at the demarcation point of 120 behavior, and specify that the number of digits of the output file name is 3:

[root@linuxcool] # csplit-n 3 filename 120

Cut the text file textfile into 2 pieces at the demarcation point of 120 behavior, and specify that the leading edge of the output file name is fileName digits:

[root@linuxcool] # csplit-f fileName testfile 120

Split the file filename 8 times in 10 behavior units and specify the format of the output file name:

[root@linuxcool ~] # csplit-b "myfile%o% filename 10 {8}

Split the text file filename by every 20 behavior units:

[root@linuxcool ~] # csplit filename 20 {*}

Divide the file into two parts with the string "Chapter X" as the delimiter:

[root@linuxcool ~] # csplit filename / "Chapter X" / above is the detailed content of the file split using linux's csplit command. Have you learned anything after reading it? If you want to know more about it, welcome to the industry information!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report