Linux splits files with split command


usage method:

$ split --help
Usage: split [option]... [enter [prefix]]
Split the input content into fixed size fragments and output them to "prefix AA", "prefix AB";
The default split unit is 1000 lines, and the default prefix is "X". If no input is specified, or if the input is "-", the data is read from the standard input.

Parameters that must be used for long options are also required for short options.
  -a. -- suffix length = n specifies that the suffix length is n (default is 2)
  -b. -- bytes = size specifies the byte size of each output file
  -C. -- line bytes = size specifies the maximum line byte size in each output file
  -d. -- numeric suffixes use numeric suffixes instead of letter suffixes
  -l. -- lines = a value that specifies how many lines each output file has
      --Hibernate outputs file characteristics before each output file is opened
      --Help displays this help message and exits
      --Version displays version information and exits

Size can be an optional integer followed by one of the following units:
KB 1000, K 1024, MB 1000 * 1000, m 1024 * 1024, and G, t, P, e, Z, y.

Examples of use:

#Cut the file according to 200 lines, the file prefix is out, and the suffix is 4 for the length of the number
split -l 200 -d -a 4 input_file out
#Cut the file by 2m, the file prefix is log, and the suffix is letter
split -b 2M input_file log

Recommended Today

How to share queues with hypertools 2.5

Share queue with swote To realize asynchronous IO between processes, the general idea is to use redis queue. Based on the development of swote, the queue can also be realized through high-performance shared memory table. Copy the code from the HTTP tutorial on swoole’s official website, and configure four worker processes to simulate multiple producers […]