paste

From NetBSD Wiki

Jump to: navigation, search

The paste(1) command lets you paste lines of files together.

Example:

$ cat foo
hello,
this is
NetBSD is
$ cat bar
world!
strange fun
very JIHBED!
$ paste foo bar
hello,  world!
this is strange fun
NetBSD is      very JIHBED!

By default, paste uses the tab character to paste together the lines of the files side-by-side. You can also use another separator character:

$ paste -d : foo bar
hello,:world!
this is:strange fun
NetBSD is:very JIHBED!

There's also a way to paste 'vertically' instead of 'horizontally': this pastes the lines of the first file after eachother, followed by a newline and then the lines of the second file (and then the third, fourth etc):

$ paste -s foo bar
hello,  this is NetBSD is
world!  strange fun   very JIHBED!

Or if you have a file which contains a series of numbers:

$ cat numbers
1
2
3
4
5
$ paste -s -d + numbers
1+2+3+4+5
$ paste -s -d + numbers | bc
15

You can use the name '-' if you want to refer to standard input at that file position:

$ echo 'Strange\nWe are having\nPaste is' | paste - bar
Strange world!
We are having   strange fun
Paste is        very JIHBED!

See also

View source code (Please report any bugs or suggestions here).

Retrieved from "http://wiki.netbsd.se/paste"
Personal tools