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 the split command in Linux

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

Share

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

This article mainly shows you "how to use the split command in Linux". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn how to use the split command in Linux.

Linux common command split command can split a large file into many small files, sometimes need to split the file into smaller fragments, such as to improve readability, generate logs, and so on.

Split splits files of any size

Option-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 rows per output file. -a: specify the suffix length (default is 2). Instance generates a test file with the size of 100KB:

[root@localhost split] # dd if=/dev/zero bs=100k count=1 of=date.file 1: 0 records in 1: 0 records out 102400 bytes (102kB) copied, 0.00043 seconds, 238 MB/s use the split command to split the date.file file created above into small files of 10KB size:

[root@localhost split] # split-b 10k date.file [root@localhost split] # ls date.file xaa xab xac xad xae xaf xag xah xai xaj file is split into multiple suffix files with letters. You can use the-d parameter if you want to use the numeric suffix, and you can use-a length to specify the length of the suffix:

[root@localhost split] # split-b 10k date.file-d-a 3 [root@localhost split] # ls date.file x000x001 x002 x003 x004 x005 x006 x007 x008 x009 specify the prefix of the file name for the split file:

[root@localhost split] # split-b 10k date.file-d-a 3 split_file [root@localhost split] # ls date.file split_file000 split_file001 split_file002 split_file003 split_file004 split_file005 split_file006 split_file007 split_file008 split_file009 use the-l option to split a file based on the number of lines in the file, for example, to split the file into small files containing 10 lines:

Split-l 10 date.file and above are all the contents of this article entitled "how to use split commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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