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

How to use split to cut and merge files under Linux

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use split to cut files and merge files under Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Split uses split: you can split a large file into many small files, and sometimes you need to split the file into smaller fragments, such as generating logs to improve readability

Syntax: split (option) (file) PREFIX

Options:

-b: the value is the size of each output file, in byte.

-C: the maximum number of byte per line in each output file.

-d: use numbers as suffixes.

-l: the value is the number of columns per output file.

PREFIX: stands for the leading character and can be used as the leading file of the cutting file.

Example:

1) there is an 11m logs that needs to be cut into 1m files

Split-b 1m logs

2) the file is divided into multiple suffix files with letters. If you want to use a numeric suffix, you can use the-d parameter, and you can use-a length to specify the suffix length:

Split-b 1m logs-d-a 2

3) specify the prefix of the file name for the split file:

Split-b 1m logs-d-a 2 file_split

4) use the-l option to split the file according to the number of lines of the file, for example, to split the file into small files containing 100 lines each

Split-l 100 logs

5) after the file is cut and moved to the corresponding directory, you need to merge the file to get the original file (PS: verify md5 for transferring files)

Cat x * > log diff-r log logs

No output after diff, indicating that the two files are consistent

Thank you for reading this article carefully. I hope the article "how to use split to cut and merge files under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Development

Wechat

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

12
Report