In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to achieve file cutting 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.
File segmentation under linux can be achieved through the split command, and you can specify two modes: split by number of lines and split by size. File merging under Linux can be realized by cat command, which is very simple.
1. File cutting-split
It is convenient to use split command to cut large files under Linux system.
[1] Command syntax
#-a: specify the suffix length of the output file name (default is 2: aa,ab...) #-d: specify that the suffix of the output file name is replaced by a number #-l: number of lines split mode (specify how many lines are cut into a small file The default number of lines is 1000 lines) #-b: binary split mode (supported unit: KAGIA) #-C: file size split mode (try to maintain the integrity of each line when cutting) split [- a] [- d] [- l] [- b] [- C] [file to be cut] [output file name]
[2] use examples
# Line cut file $split-l 300000 users.sql / data/users_# uses the numeric suffix $split-d-l 300000 users.sql / data/users_# to split $split-d-b 100m users.sql / data/users_ by byte size
[3] help information
# help information $split-- helpUsage: split [OPTION]. [FILE [PREFIX]] Output pieces of FILE to PREFIXaa, PREFIXab,...; default size is 1000 lines, and default PREFIX is' x'.With no FILE, or when FILE is -, read standard input.Mandatory arguments to long options are mandatory for short options too. -a,-- length of the suffix-length=N generate suffixes of length N (default 2) suffix name (default is 2)-- additional-suffix=SUFFIX append an additional SUFFIX to file names-b,-- bytes=SIZE put SIZE bytes per output file byte size of each output file-C -- the maximum byte size of each output file of line-bytes=SIZE put at most SIZE bytes of records per output file-d use numeric suffixes starting at 0. Not alphabetic uses numeric suffixes instead of letter suffixes-- numeric-suffixes [= FROM] same as-d, but allow setting the start value-e -- elide-empty-files do not generate empty output files with'--n' does not produce an empty output file-- filter=COMMAND write to shell COMMAND File name is $FILE is written to the shell command line-l,-- lines=NUMBER put NUMBER lines/records per output file sets the number of lines per output file-n,-- number=CHUNKS generate CHUNKS output files; see explanation below produces the chunks file-t,-- separator=SEP use SEP instead of newline as the record separator Use the new character division'\ 0' (zero) specifies the NUL character-u,-- unbuffered immediately copy input to output with'- n rbank.' No cache required-- verbose print a diagnostic just before each displays split progress output file is opened-- help display this help and exit displays help information-- version output version information and exit displays version information The SIZE argument is an integer and optional unit (example: 10K is 101024). Units are K M powers of, G, T, P, E, E, Y, Y, E, E, Y, Y, E, Y, Y, E, E, Y, Y, E, Y, M, E, Y, Y, M, P, P, E, Y, Y (powers of 1024), P, etc. (powers of 1000). CHUNKS may be: N split into N files based on size of input K split into N files without splitting lines/records l/K/N output Kth of N to stdout without splitting lines/records N output Kth of N to stdout L but use round robin distribution r/K/N likewise but only output Kth of N to stdoutGNU coreutils online help N like'l but use round robin distribution r/K/N likewise but only output Kth of N to stdoutGNU coreutils online help: Full documentation at: or available locally via: info'(coreutils) split invocation'2. File merge-cat
It is also convenient to merge multiple small files by using the cat command under the Linux system.
[1] Command syntax
#-n: display line number #-e: end each line with the $character #-t: display the TAB character (^ I) cat [- n] [- e] [- t] [output file name]
[2] use examples
# merge file $cat / data/users_* > users.sql
[3] help information
# help information $cat-- hUsage: cat [OPTION]. [FILE]... Concatenate FILE (s) to standard output.With no FILE, or when FILE is -, read standard input. -A,-- show-all equivalent to-vET-b,-- number-nonblank number nonempty output lines, overrides-n-e equivalent to-vE-E,-- show-ends display $at end of each line-n,-- number number all output lines-s,-- squeeze-blank suppress repeated empty output lines-t equivalent to-vT-T -- show-tabs display TAB characters as ^ I-u (ignored)-v,-- show-nonprinting use ^ and M-notation, except for LFD and TAB-- help display this help and exit-- version output version information and exitExamples: cat f-g Output f's contents, then standard input, then g's contents. Cat Copy standard input to standard output.GNU coreutils online help: Full documentation at: or available locally via: info'(coreutils) cat invocation' Thank you for reading this article carefully. I hope the article "how to achieve File cutting under Linux" shared by the editor will be helpful to you. At the same time, I also hope you will 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.