Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the paste command to process strings in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to use the paste command to deal with strings in Linux, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.

Name: paste

Location: / usr/bin/paste

Permissions: all users

Function: two corresponding lines of multiple files are pasted together

Usage: paste [OPTION]. [FILE]...

Options:

-d connects the delimiter of two lines. The default is [TAB] as the delimiter.

If the file is partially written, then it represents the data from the standard input

The code is as follows:

$cat a

Pa:11:a

Sa:32:c

App:5:b

Stort:1:d

Pear:4:aa

Hello:3:f

$cat b

Acccc

A b

C

B dd

D aa

A c

B

F dd

$paste a b

Pa:11:an acccc

Sa:32:c a b

App:5:b c

Stort:1:d b dd

Pear:4:aa d aa

Hello:3:f a c

B

F dd

The code is as follows:

$paste-d "," a b specifies a comma as the delimiter

Pa:11:a, acccc

Sa:32:c,a b

App:5:b, c

Stort:1:d,b dd

Pear:4:aa,d aa

Hello:3:f,a c

, b

, f dd

Example of file Writing -, specifying @ as the delimiter

The code is as follows:

$cat b | paste-d "@" a-

Pa:11:a@ acccc

Sa:32:c@a b

App:5:b@ c

Stort:1:d@b dd

Pear:4:aa@d aa

Hello:3:f@a c

@ b

@ f dd

On how to use the paste command in Linux to deal with strings is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report