Dug  InThaMud
Dug InThaMud

Reputation: 3

Writing curl output to a shell variable. CURL output is being condensed to 1 line. Newline missing?

I am trying to retrieve the contents of a .html file into a variable using the following:

data=$(curl --silent "$url");

If I echo $data I get the follwing:

 </html>of_Hg_sensor_2 -23.29362<br/>eta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta></head>

It appears that it's never starting a new line and simply keeps dumping each successive line over the last.

If I run the same 'curl --silent "$url"' in a shell or redirect output to a file everything looks fine. I've tried running in sh and bash.

I know I could simply retrieve the file but I'd like to avoid a file writes as this will be a heavily repeated process.

I've got to be missing something simple/stupid?

Upvotes: 0

Views: 2090

Answers (1)

badams
badams

Reputation: 108

echo "$data"

Without the double quotes, the newlines are converted to spaces.

Upvotes: 1

Related Questions