paste命令使用
linux上一个合并文件的命令,可以按行来进行合并:
,表明合并的分隔符paste -d ',' b.txt m.txt >n.txt-表明从标准输入获取文件cat b.txt |paste - m.txt > n.txt如果要合并一个文件的所用行paste -s b.txt > n.txt该命令主要用来将多个文件的内容合并,与cut命令完成的功能刚好相反。使用事例:$ cat namesTonyEmanuelLucyRalphFredgan.cublog.cn$ cat numbers(307) 555-5356(212) 555-3456(212) 555-9959(212) 555-7741(212) 555-0040$ paste names numbers 将两个文件合并,他们中间用tab键分隔开Tony (307) 555-5356Emanuel (212) 555-3456Lucy (212) 555-9959Ralph (212) 555-7741Fred (212) 555-0040gan.cublog.cn$ cat addresses55-23 Vine Street, Miami39 University Place, New York17 E. 25th Street, New York38 Chauncey St., Bensonhurst17 E. 25th Street, New Yorkgan.cublog.cn$ paste names addresses numbersTony 55-23 Vine Street, Miami (307) 555-5356Emanuel 39 University Place, New York (212) 555-3456Lucy 17 E. 25th Street, New York (212) 555-9959Ralph 38 Chauncey St., Bensonhurst (212) 555-7741Fred 17 E. 25th Street, New York (212) 555-0040$ paste -d'+' names addresses numbers 他们中间用指定的'+'符号隔开Tony+55-23 Vine Street, Miami+(307) 555-5356Emanuel+39 University Place, New York+(212) 555-3456Lucy+17 E. 25th Street, New York+(212) 555-9959Ralph+38 Chauncey St., Bensonhurst+(212) 555-7741Fred+17 E. 25th Street, New York+(212) 555-0040$ paste -s names 将多行数据合并到一行,他们间用tab键隔开Tony Emanuel Lucy Ralph Fred