(ext.) Linux Paste command usage detailed

Source: Internet
Author: User

Linux Paste Command Usage detailed
Original: http://www.xfcodes.com/linuxcmd/mulu/10211.htm
Linux under the Paste command, which can be used to merge columns of files.

Feature Description: Merge the columns of the file.
Syntax: paste [-s][-d][--help][--version][file ...]
Additional note: The Paste directive merges each file in a column-by-column basis.

Parameters

-D or--delimiters= replaces the skip character with the specified interval character.
-S or--serial strings are processed instead of parallel.
--help online Help.
--version Displays help information.

In Linux, cut is used to extract data columns or fields from a text file or standard output, and then use paste to paste the data into a related file.
When pasting data from two different sources, you first need to categorize them and make sure that two files are the same number of rows.

Paste will put different file line information on one line.
By default, when you paste a connection, separate text from the new line is separated by a space or Tab key, which becomes a domain delimiter unless you specify the-D option.

The paste format is:
Paste-sd-file1


The paste format is:
Paste-d-s-file1 File2
The options have the following meanings:

-d Specifies a field delimiter that differs from the Space or TAB key. For example, use @ to separate the fields, using-D @.
-S merges each file into rows instead of by line.
-Use standard input. For example, Ls-l |paste, which means that the output is displayed on only one column.

examples of Linux paste commands .

Example:

Copy CodeCode Sample:wangnc> PG PAS1
ID897
ID666
ID982
Wangnc> PG PAS2
P.jones
S.round
L.clip

1, the basic Paste command pastes the PAS1 and pas2 two files into two columns:

Copy CodeCode sample:wangnc> Paste Pas1 pas2
ID897 P.jones
ID666 S.round
ID982 L.clip

2, you can specify which column to stick first by exchanging the file name:

Copy CodeCode sample:wangnc> Paste Pas2 pas1
P.jones ID897
S.round ID666
L.clip ID982

3, to create a field separator that differs from the Space or TAB key, use the-D option. The following example uses a colon to make a field delimiter.

Copy CodeCode sample:wangnc> paste-d: Pas2 pas1
p.jones:id897
s.round:id666
l.clip:id982

4, to merge two rows instead of pasting by row, you can use the-s option. In the following example, the first line is pasted as the ID number and the second row is the name.

Copy CodeCode sample:wangnc> Paste-s pas1 PAS2
ID897 ID666 ID982
P.jones S.round L.clip

The Paste command also has a very useful option (-).
Read the data from the standard input for each one (-). Displays a list of directories in a 6-column format using spaces as field separators.
1, the method is as follows:

Copy CodeCode Sample:wangnc> Ls/etc | Paste-d ""------
MANPATH PATH Shlib_path Snmpagent.d/timezone x11/
acct/[email protected] [email protected] audeventstab [email protected] Auto_master
Auto_parms.log auto_parms.log.old [email protected] backup.cfg [email protected] [email protected]
[Email protected] bootptab [email protected] [email protected] [email protected] [email protected]
[Email protected] cmcluster/cmcluster.conf cmom.conf [email protected] [email protected]
Copyright [email protected] csh.login [email protected] [email protected] [email protected]

2, you can also display the output in a single column format:

Copy CodeCode Sample:wangnc> Ls/etc | Paste-d ""-
MANPATH
PATH
Shlib_path
snmpagent.d/
TIMEZONE
x11/
acct/
[Email protected]
[Email protected]
Audeventstab
[Email protected]
Auto_master
Auto_parms.log
Auto_parms.log.old
[Email protected]
Backup.cfg

(GO) Linux Paste command usage detailed

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.