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 know that to symbolize a new line, I would do echo -e "line 1 \nline 2" > text.txt. I find that using \n repeatedly can be annoying, and I would to know if there a way to actually go down a line in the terminal without it executing commands. Like if I were to edit python in the terminal I could write

def main():
    print "hello world"

And pressing "enter" to go to a new line wouldn't have executed def main(): , it just went to a new line. Is there anything similar to this in the normal terminal?

share|improve this question

If you just want to echo text as in your example, you can just use the Enter key in place of \n like this:

echo "line 1
line 2" > text.txt

For that to work, you have to surround your text with "" as shown or with ''.

If you want to enter a sequence of commands without executing them until you're done, you can begin the sequence with a { and end it with a }, like this:

echo line 1
echo line 2

You can also redirect the output of the whole sequence by following the closing } with your redirection, as

echo line 1
echo line 2
} > text.txt
share|improve this answer
I want to be able to do what you did in the first example, but every time I hit enter it executes the command – WillumMaguire Oct 9 '12 at 0:52
@WillumMaguire: If you typed echo "line 1 with only one " and hit Enter, I would expect you to see the secondary prompt > . If not that, then an error message about an unterminated string. What exactly are you typing that is executed when you hit Enter? – garyjohn Oct 9 '12 at 1:41
I just tried this: echo "line 1 I also tried using E0F, but I can't seem to get it to work correctly – WillumMaguire Oct 9 '12 at 3:09
@WillumMaguire: I'm sorry, but I am unable to explain the behavior you are seeing. I tried a few different shells but always saw one of the two results I mentioned above. I also skimmed the bash(1) man page but did not see any options that would cause that behavior. – garyjohn Oct 9 '12 at 4:05

In addition to the unmatched quotation mark, you can use heredocs:

$ python <<EOF
> def main():
>       print "Hello"
> main()

Note that EOF is simply a common and convenient delineator, any token will do.

share|improve this answer

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.