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'm echoing a heredoc into a file, but the line breaks are being lost

Running this script



mkdir -p $NAME

name = "$NAME"
type = "test"

echo $FILE > $NAME/$NAME.txt

With the arg: foo, results in the file at foo/foo.txt containing

name = "foo" type = "test"

Any ideas? Thanks

share|improve this question
Is it on cygwin? is your result from a text editor or a cat? in other words, could it be that the newlines are here but not shown (because of the win/linux endlines differences)? Have you tried adding "\n"s? – m4573r Dec 19 '13 at 11:43
i tried putting in \n but it came through as plain text. was doing all through linux terminal – joevallender Dec 19 '13 at 11:51
up vote 2 down vote accepted

Always use double quotes for variables that contain whitespace:

echo "$FILE" > ...
share|improve this answer
ah - of course. great! thanks :) – joevallender Dec 19 '13 at 11:52

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.