[Linux] common command paste command

paste - merge lines of files

paste command is used to merge files listed.

paste command file will in columns of each column, a column to be incorporated.

 

Syntax:  Paste [OPTION] ... [FILE] ...

parameter:

  • -d <character spacing> or --delimiters = <spaced Characters>
    • Replace the character with the specified interval tab character.
      • [root @ Oldboy Oldboy] # Paste number.txt name.txt -d:        
        . 1 : User01
         2 : named user02
         . 3 : user03
         . 4 : user04
         . 5 : user05 
        
        # -d parameter may be specified by various delimiter, list 
        [root @ Oldboy Oldboy] # Paste number.txt name.txt number.txt -d "= ;:" 
        . 1 = User01;. 1 
        2 = named user02; 2 
        . 3 = user03;. 3 
        . 4 = user04;. 4 
        . 5 = user05;. 5

         

  • -s or --serial
    • Performed in parallel rather than serial processing.
    • [root@oldboy oldboy]# paste number.txt name.txt -d "," -s 
      1,2,3,4,5
      user01,user02,user03,user04,user05

       

Example:

1  # Data Preparation 
2 [the root @ Oldboy Oldboy] # SEQ. 5> number.txt        
. 3 [the root @ Oldboy Oldboy] # echo User {01..05} | xargs -n1> name.txt 
. 4 [the root @ Oldboy Oldboy] # {} a..e school_ echo> school.txt 
. 5  
. 6  # view data 
. 7 [the root @ Oldboy Oldboy] # CAT number.txt name.txt school.txt 
. 8 . 1
 . 9 2
 10 . 3
 . 11 . 4
 12 is . 5
 13 is  User01
 14  named user02
 15  user03
 16  user04
 17 user05
 18 is  school_a school_b school_c school_d school_e
 . 19  
20 is  # three combined file 
21 is [the root @ Oldboy Oldboy] # Paste number.txt name.txt school.txt     
22 is . 1        User01 school_a school_b school_c school_d school_e
 23 is 2        named user02
 24 . 3        user03
 25 . 4        user04
 26 5 user05

 

Loading data from the standard input:

[root@oldboy oldboy]# seq 10 > seq_1.txt
[root@oldboy oldboy]# paste -d ',' - - <seq_1.txt 
1,2
3,4
5,6
7,8
9,10

 

Guess you like

Origin www.cnblogs.com/zoe233/p/11802520.html