Recently, the logs for new projects are very large, and it is very difficult to use vim to open them.
You can use the split tool to split files and then open them easily.
Split Command-split files
Syntax: split [-help] [-version] [-] [-l] [-B] [-C] [-d] [-a] [file to be cut] [output file name]
-Version: displays version information.
-Or-l: specifies the number of lines to be cut once for text file splitting.
-B: specifies the size of the cut file, in MB or k.
-C is similar to-B, but the integrity of each line should be maintained as much as possible.
-D. Use numbers instead of letters as the suffix.
-A specifies the length of the suffix. The default value is 2 characters.
Usage:
Shell
Split parameters:
-B: the size of the file to be split. The unit can be added, for example, B, k, and m;
-L: split by the number of rows;
# Split the sync. log file into 1 GB files. Put the split files in the/tmp/sync Directory, starting with the synccut file name.
Split-B 1G sync. log/tmp/sync/synccut
# Split the sync. log file into files of every 1000 lines. Put the split files in the/tmp/sync Directory, starting with the synccut file name.
Split-l 1000 sync. log/tmp/sync/synccut
Example 1
Cut the.tar.gz package to 5 MB in size:
Split-B 5 m a.tar.gz. The output file name is a.tar.gz. ". If this parameter is not specified, it will be output in the form of xaa, xab, and xac. If the file name is not followed by ".", the output file name will be connected with the suffix rather than intuitive.
Example 2
Use the "|" pipe to merge the packaging and splitting actions:
Tar-zcf-a | split-B 5 m-a.tar.gz. note: "-" cannot be omitted before and after the pipeline. It is used as the input parameter of tar ouput and split.
Run the command "split" to cut the file "README" into a file every six lines. Run the following command:
$ Split-6 README # split each six lines of the README file into one file
After the preceding command is executed, the command "split" will cut the original large file "README" into multiple small files starting with "x. In these small files, each file has only six lines of content.
Run the "ls" command to view the current directory structure, as shown below:
$ Ls # execute the ls command
# Obtain the current directory structure
README xaa xad xag xab xae xah xac xaf xai