Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

Perl solution:

perl -pechomp file1 > file2
share|improve this answer

(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

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.