Shell text filtering programming (11): paste command

Source: Internet
Author: User

Tag: script

[Copyright statement: reprinted. Please retain the Source: blog.csdn.net/gentleliu. Mail: shallnew at 163 dot com]
It can be seen from the literal that the paste command and the cut command have the opposite function. The cut command extracts fields from the file line, while the paste command merges the file line information into one line.
The paste command is used as follows:

paste -d -s -file1 file2

The-s option combines the file rows into one row.
For example, the following files are available:

# paste 1.filenameallenbobchrisdyao
# paste 1.file -s name    allen    bob    chris    dyao

This command combines each line of the file into one line separated by the tab key.

-D specifies the separator. For example:

# paste -s -d - 1.file name-allen-bob-chris-dyao


Paste can splice multiple files by column, as shown below:

# paste 1.file 2.file  3.filename    sex    ageallen    mail    25bob    female    27chris    male    56dyao    mail    14    female    19

You can also splice multiple files by column:
# paste 1.file 2.file  3.file -sname    allen    bob    chris    dyaosex    mail    female    male    mail    femaleage    25    27    56    14    19

Of course, you can also specify the separator Number:
# paste 1.file 2.file  3.file -s -d:name:allen:bob:chris:dyaosex:mail:female:male:mail:femaleage:25:27:56:14:19

Or
# paste 1.file 2.file  3.file -d:name:sex:ageallen:mail:25bob:female:27chris:male:56dyao:mail:14:female:19

 

 


 

Shell text filtering programming (11): paste command

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.