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?


The correct way to print is

echo "$ifc"
| improve this answer | |
  • Works! Why, though? – Armand 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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