O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.6. Using paste

Using cut you extract columns or fields of data from a text file or standard input. With paste you can then use this data to paste the contents of the file together. When pasting data from two different sources, it pays to sort them first; you should also make sure that the two files have an equal number of lines.

Paste puts the text together in a row by row method. By default, when paste joins, it converts all the new lines into tabs or spaces unless the ‘ -d ’ option is specified, then this will become the field separator.

The format for paste is:

paste -d -s - file1 file2 

Let’s look at the options.

-d Tells paste to use a different field delimiter, rather then a tab or space; for example, to separate the fields using an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required