difference between lam and paste

5

1

I don't get the difference between the program lam

lam -- laminate files
The lam utility copies the named files side by side onto the standard output. The n-th input lines from the input files are considered fragments of the single long n-th output line into which they are assembled. The name `-' means the standard input, and may be repeated.

and paste

paste -- merge corresponding or subsequent lines of files
The paste utility concatenates the corresponding lines of the given input files, replacing all but the last file's newline characters with a single tab character, and writes the resulting lines to standard output. If end-of-file is reached on an input file while other input files still contain data, the file is treated as if it were an endless source of empty lines.

Except for the command options. I don't get the difference. Suppose I have two files a and b

a
------------
1
2
3

b
------------
4
5
6

I get

$ paste -d ',' a b
1,4
2,5
3,6

$ lam a -s',' b
1,4
2,5
3,6

They seem redundant in scope, although lam seems to be more flexible. The descriptions do not allow me to catch cases where they could behave differently. Does anybody have a clue ?

Stefano Borini

Posted 2009-07-29T15:04:55.550

Reputation: 2 034

@RichardHoskins In my opinion that's good enough to be an answer. Thanks! – isomorphismes – 2014-08-13T22:22:10.997

4They are redundant in scope. lam was part of BSD, paste AT&T. paste was later standardized in POSIX.2. lam hangs around for hysterical reasons. TIMTOWTDI – Richard Hoskins – 2009-07-29T17:18:08.480

Answers

4

paste applies to complete files. Therefore it will concatenate complete files into a single file. Lines will be merge if they are the same.

lam applies to lines in a file as well as files. Therefore you can selectively concatenate lines into a new file.

BinaryMisfit

Posted 2009-07-29T15:04:55.550

Reputation: 19 955

1

Interesting, I have mostly used join for these things. http://linux.about.com/library/cmd/blcmdl1_join.htm

– nik – 2009-07-29T15:27:52.493

@nik. So do I - Or I just do a copy – BinaryMisfit – 2009-07-29T15:40:48.333

1

With lam you can use delimiters with more than one character.

niless

Posted 2009-07-29T15:04:55.550

Reputation: 11