Newline in bash variable

bashnewlinesscriptshell

My script contains something like this:

ifc=$(ifconfig)

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?

Best Answer

The correct way to print is

echo "$ifc"
Related Question