In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use linux's paste command to merge two files, which has certain reference value and can be used for reference by friends who need it. Let's take a look at it with me.
The paste command merges each file column by column, column by column, which is equivalent to pasting the contents of two different files together to form a new file.
Note: the paste default paste method pastes as columns, but it is not impossible to paste as rows. Add the-s option to paste in rows.
Syntax format: paste [parameters] [File 1] [File 2]
Common parameters:
The delimiter of the-d default field is the space or tab key, set the new field delimiter-s paste each file into a line-read data from standard input
Reference example
Paste file_2 and file_2 into a new file:
[root@linuxcool ~] # cat file_1
Aaa
Bbb
Ccc
Ddd
Eee
[root@linuxcool ~] # cat file_2
AAA
BBB
CCC
DDD
EEE
[root@linuxcool ~] # paste file_1 file_2
Aaa AAA
Bbb BBB
Ccc CCC
Ddd DDD
Eee EEE
Set the domain delimiter to: paste into a new file:
[root@linuxcool ~] # paste-d: file_1 file_2
Aaa:AAA
Bbb:BBB
Ccc:CCC
Ddd:DDD
Eee:EEE
Paste each file into a line:
[root@linuxcool ~] # cat file_1
Aaa
Bbb
Ccc
Ddd
Eee
[root@linuxcool ~] # cat file_2
AAA
BBB
CCC
DDD
EEE
[root@linuxcool] # paste-d:-s file_1 file_2
Aaa:bbb:ccc:ddd:eee
AAA:BBB:CCC:DDD:EEE
Read data from standard input, showing 5 file names per line:
[root@linuxcool ~] # ls | paste-d ""-
Anaconda-ks.cfg dir_1 file1 file_1 file_1.db
File_2 file_3 file_4 file_5 file_6
File.db file_hobby_1 file_hobby.db file_hobby_sort.db file_sort.db
Initial-setup-ks.cfg testfile above is how to use linux's paste command to merge the details of the two files, after reading it, do you have anything to gain? If you want to know more about it, welcome to the industry information!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.