草草晴空

Simple Coder

Unix Paste

$ cat names
Tony
Emanuel
Lucy
Ralph
Fred
$

$ cat numbers
(307) 555-5356
(212) 555-3456
(212) 555-9959
(212) 555-7741
(212) 555-0040
$

$ paste names numbers Paste them together
Tony (307) 555-5356
Emanuel (212) 555-3456
Lucy (212) 555-9959
Ralph (212) 555-7741
Fred (212) 555-0040
$

$ cat addresses
55-23 Vine Street, Miami
39 University Place, New York
17 E. 25th Street, New York
38 Chauncey St., Bensonhurst
17 E. 25th Street, New York

$ paste names addresses numbers
Tony 55-23 Vine Street, Miami (307) 555-5356
Emanuel 39 University Place, New York (212) 555-3456
Lucy 17 E. 25th Street, New York (212) 555-9959
Ralph 38 Chauncey St., Bensonhurst (212) 555-7741
Fred 17 E. 25th Street, New York (212) 555-0040
$

paste -dchars 用chars来做分隔符,第一个字符分隔第一个和第二个字符串,第二个字符分隔第二个和第三个字符串,依此类推.分隔符要用' '号标记
$ paste -d'+' names addresses numbers
Tony+55-23 Vine Street, Miami+(307) 555-5356
Emanuel+39 University Place, New York+(212) 555-3456
Lucy+17 E. 25th Street, New York+(212) 555-9959
Ralph+38 Chauncey St., Bensonhurst+(212) 555-7741
Fred+17 E. 25th Street, New York+(212) 555-0040
$

$ paste -d'+-' names addresses numbers
Tony+55-23 Vine Street, Miami-(307) 555-5356
Emanuel+39 University Place, New York-(212) 555-3456
Lucy+17 E. 25th Street, New York-(212) 555-9959
Ralph+38 Chauncey St., Bensonhurst-(212) 555-7741
Fred+17 E. 25th Street, New York-(212) 555-0040
$

paste -s filename 是把一个文件里的内容打印在一行里

$ paste -s names Paste all lines from names
Tony Emanuel Lucy Ralph Fred
$ ls | paste -d' ' -s - Paste ls's output, use space as delimiter
addresses intro lotsaspaces names numbers phonebook
$
阅读更多
文章标签: unix numbers output
个人分类: Search
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭