Merge text files by column in Linux

Source: Internet
Author: User
In Linux, text files are merged by column-Linux general technology-Linux programming and kernel information. For details, refer to the following section. I want to combine the file1 and file2 of a text file into a file file3 according to the corresponding rows. As follows:

Original file file1:
Aaaa
Bbbb
Cccc
Dddd
Eeee

Original file file2:
1111
2222
3333
4444
5555

Merged file file3:
Aaaa 1111
Bbbb 2222
Cccccc 3333
Dddddd 4444
Eeeeee 5555

At the beginning, I used VIM to implement the VI advanced command collection and VIM application instances, but it was quite troublesome. After exploration, I found that using the paste command to implement this function is relatively simple, and using the paste file1 file2> file3 command to solve the problem.

The following describes how to use paste:
1. syntax structure: paste [OPTION]... [FILE]...

2. option can be the following parameter:
-D, -- delimiters = LIST: each row is separated by a specified character.
-S, -- serial: horizontally arrange the first file, and then horizontally arrange the second file...
-- Help: displays help
-- Version: displays the version number.

3. There can be multiple files. We can merge multiple files at the same time. For example, paste file1 file2 file3 can merge three files at the same time.

The above are just some tips I have found during the use of linux and hope to help you.
Related Article

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.