Linux多文件按行拼接整合命令paste

Linux下的paste命令主要用于从多个文件(包括标准输入)中读取内容,将每个文件的对应行用指定分隔符(默认tab制表符)拼接起来并打印到标准输出,我们可以使用重定向命令“>”将输出结果保存到文件中,从而实现整合多个文件的功能。

常用参数:

  1. -d<分隔符> 指定分隔符,若未使用该参数则默认制表符分隔  
  2. -s 不使用平行的行目输出模式,而是每个文件占用一行  

   

应用实例:paste命令整合多个文件

view plain copy to clipboard print ?
  1. trevor@trevor-PC:~/linux/linux100$ cat username  
  2. 张三  
  3. 李四  
  4. 王五  
  5. trevor@trevor-PC:~/linux/linux100$ cat usermail  
  6. [email protected]  
  7. [email protected]  
  8. [email protected]  
  9. trevor@trevor-PC:~/linux/linux100$ cat userjob  
  10. 程序员  
  11. 销售  
  12. 财务  
  13. trevor@trevor-PC:~/linux/linux100$ paste username usermail userjob  
  14. 张三 [email protected] 程序员  
  15. 李四 [email protected] 销售  
  16. 王五 [email protected] 财务  
  17. trevor@trevor-PC:~/linux/linux100$ paste -s username usermail userjob  
  18. 张三 李四 王五  
  19. [email protected] [email protected] [email protected]  
  20. 程序员 销售 财务  
  21. trevor@trevor-PC:~/linux/linux100$ paste -d '/' username usermail userjob  
  22. 张三/[email protected]/程序员  
  23. 李四/[email protected]/销售  
  24. 王五/[email protected]/财务  
  25. trevor@trevor-PC:~/linux/linux100$  

你可能感兴趣的:(Linux多文件按行拼接整合命令paste)