Linux commands (12) Split file split merge file join

Source: Internet
Author: User

First, split file split command introduction

When working with files, sometimes you need to split the file, Split command for splitting the file, you can split the text file, divided by the number of lines specified, each split file contains the same number of rows. Split can split non-text files, the partition can specify the size of each file, the split file has the same size. The files after split can be assembled with cat commands.

Common parameter Description
-a 指定分割文件时前缀的长度,默认为2-b 指定分割每个文件的大小,以字节为单位-C 指定每个文件中单行的最大字节数-d 使用数字前缀而非字符前缀-l 指定分割文件每个包含多少行--verbose 输出执行时的诊断信息--version 输出版本信息
Instance

Split the file by default by 1000 lines

split src.txt

Split by 3 per file

I want to add .....

Ii. Introduction to merge File Join command

If you need to connect two files according to a certain rule, join can do this function, the command can find two files in the same column content of the same row, and merge, and then output to the standard output device.

Common parameter Description
-a<1 或 2>  除了显示原来的输出内容之外,还显示命令文件中没用相同列的行-e<字符串> 若 文件1 与 文件2 中找不到指定的列,则在输出中填入选项中的字符串-i  比较内容时忽略大小写差异-o<格式>      按照指定的格式来显示结果-t<字符>      指定列的分隔符-v<1 或 2>   跟 -a 相同,到那时只显示文件中没有相同的列-1<列>       指定匹配列为第一个文件中的某列,如果不指定,默认为第一列-2<列>       指定匹配列为第二个文件中的某列,如果不指定,默认为第一列--help 显示帮助
Instance

Merging files

join src dst | cat -n

Specify output-specific columns

join -o1.1 -o2.2, 2.3 src dst   

These two commands do not know very well, write down first!

Linux commands (12) Split file split merge file join

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.