Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a testA.txt with contents as shown below

[jiewmeng@JM textFiles]$ cat testA.txt 
The quick
brown fox
jumped over
the lazy 
dog.

paste normally works

[jiewmeng@JM textFiles]$ paste testA.txt 
The quick
brown fox
jumped over
the lazy 
dog.

But what happened when I used serial?

[jiewmeng@JM textFiles]$ paste -s testA.txt 
The quicdog.lazy er

[jiewmeng@JM textFiles]$ paste -s -d- testA.txt 
-dog.lazy er

I was expecting output similar to

[jiewmeng@JM tmp]$ echo -en "The quick\nbrown fox\njumped over\nthe lazy\ndog" | paste -s -
The quick   brown fox   jumped over the lazy    dog

Opening the file in a test editor seems to work fine, just like cat, or paste did

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Your file contains CR+LF line ending. (You can say cat -vet inputfile to figure that. Carriage returns would show up as ^M in the output.)

The following demonstrates the effect of line endings on the output:

$ cat test.txt
The quick
brown fox
jumped over
the lazy
dog.
$ paste -s test.txt
The quick       brown fox       jumped over     the lazy        dog.
$ unix2dos test.txt
$ paste -s test.txt
        dog.lazy er
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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