2

I have two files which contain only one column of numeric data each, and the same number of rows. When using paste, it does combine the rows from the two files into one row, but the text of the first file is truncated, while the text from the second file is intact:

$ head -3 s1_.dat s2_.dat
==> s1_.dat <==
-0.023193359375
-0.020416259766
0.014587402344

==> s2_.dat <==
-0.018707275391
-0.019805908203
0.011108398438

$ paste s1_.dat s2_.dat | head -3
-0.02319-0.018707275391
-0.02041-0.019805908203
0.0145870.011108398438

Are there column width limits in paste?

5

1 Answer 1

5

There shouldn't be a limit. It's just that at least your first input file has DOS/Windows -style CRLF line endings, where the carriage return (CR) returns the cursor position to the start of the line before the separating TAB and the next value are printed. Note how the value from the second file starts at position 8, at the first tab stop.

The actual output is something like this:

-0.023193359375<CR><TAB>-0.018707275391<NL>

You can verify it if you view the output with e.g. od -c, it should show \r for the CR there.

Run the files or the output through tr -d '\r' to remove the CRs. (or dos2unix or any of the other various ways.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.