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

My script contains something like this:


With this, the ifc variable contains the output of the command ifconfig but without newlines. So, when I print it with echo $ifc I get only one line.

How can I include the newlines of subcommands?

share|improve this question
up vote 9 down vote accepted

The correct way to print is

echo "$ifc"
share|improve this answer
oh! that easy... thanks :-) – Ethan Leroy Oct 1 '10 at 9:12
Works! Why, though? – Alison Apr 8 '13 at 11:22
see Word Splitting in bash(1), you need quoting to preserve the spaces, tabs, or newlines. – livibetter Apr 8 '13 at 14:30

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.