Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have something like this:

a line here;
a new line here;
another line here;

and I want it to be like, where all lines are combined into a single line.

a line here;a new line here;another line here;
share|improve this question

3 Answers 3

up vote 3 down vote accepted

tr -d '\n' <filename> will delete all newlines in the given file.

share|improve this answer
+1 for not resorting to perl for something so simple. –  mkaito Oct 27 '12 at 19:40

(Just in case someone on Windows needs this.) In PowerShell it's

-join (Get-Content filename)

or shorter:

-join(gc filename)
share|improve this answer

Perl solution:

perl -pechomp file1 > file2
share|improve this answer

Your Answer


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.