Unwanted empty lines using echo and cat [duplicate]
问题 This question already has answers here : Unwanted line break using echo and cat (3 answers) How to insert a text at the beginning of a file? (15 answers) Closed 5 years ago . I want to add a line to the beginning of a text file. I have input.txt: line1 line2 line3 and want to add the line 'time/F:x1:x2' to end up with time/F:x1:x2 line1 line2 line3 I'm trying to do this with echo 'time/F:x1:x2' | cat - input.txt>output.txt but what I get is time/F:x1:x2 line1 line2 line3 that is, I get empty