Paste:linux merge columns from two files (merge left and right)

Source: Internet
Author: User

[email protected] ~]# paste [-d] file1 file2

Options and Parameters:

-D: The delimiter character can be followed. The default is delimited by [tab]!

-: If the file section is written--indicates the meaning of the data from standard input.

Example one: Put/etc/passwd with/etc/shadow on the same line

[Email protected] ~]# Paste/etc/passwd/etc/shadow

Bin:x:1:1:bin:/bin:/sbin/nologin Bin:*:14126:0:99999:7:::

Daemon:x:2:2:daemon:/sbin:/sbin/nologin Daemon:*:14126:0:99999:7:::

Adm:x:3:4:adm:/var/adm:/sbin/nologin Adm:*:14126:0:99999:7:::

# Watch out! The middle of the same line is separated by the [tab] key!

Example two: first read the/etc/group (with cat) and then paste it together with the example! And only the first three rows are removed

[Email protected] ~]# Cat/etc/group|paste/etc/passwd/etc/shadow-|head-n 3

# The focus of this example is on that-the use! That stuff always stands for stdin Oh!

Example: Using CHPASSWD to bulk Modify user passwords

[[email protected] ~]# cat name
User1:
User2:
User3:
User4:
User5:
User6:
User7:
User8:
User9:
[[email protected] ~]# cat passwd
978ebbf1763
23c2626c37b
15dff03fa71
2459043B3AD
d317ec4870c
1728B6B5DDC
ed9d98f8b4c
0a7f3f5f8c4
96935ad635c
[[email  Protected] ~]# paste name passwd
user1:    978ebbf1763
user2:    23c2626c37b
user3:    15dff03fa71
user4:    2459043b3ad
user5:    d317ec4870c
user6:    1728B6B5DDC
user7:    ed9d98f8b4c
user8:     0a7f3f5f8c4
user9:    96935ad635c
[[email protected] ~]# paste-d "#" name passwd
User1: #978ebbf1763
User2: #23c2626c37b
User3: #15dff03fa71
User4: #2459043b3ad
user5:# d317ec4870c
User6: #1728b6b5ddc
User7: #ed9d98f8b4c
User8: #0a7f3f5f8c4
User9: #96935ad635c

Note:-d Specifies the delimiter, without which the default is a tab.

Paste:linux merge columns from two files (merge left and right)

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.