15

I have something like this

command \
second line of command \
...
...

How do I confirm so it executes?

2 Answers 2

16

The backslash (\) at the end of the line continues the command to the next line. Don't end the last line of the command with a backslash and it will execute the whole command.

If you have an unclosed quote (" or '), the command also won't complete until you close the quote. Also some uncompleted commands are detected and continue to prompt you for the rest of the command. In bash, simply typing 'if' for example won't complete until the shell sees the terminating 'fi'.

3
  • 1
    so just 'enter'? Doesn't seem to work, I just get another line of "..."
    – Blub
    Commented Nov 2, 2011 at 8:21
  • What shell are you running? This works for me in sh, bash, csh, and tcsh. Commented Nov 2, 2011 at 12:50
  • 7
    I just realized that if you have an unclosed quote (" or '), the command also won't complete until you close the quote. Also some uncompleted commands are detected and continue to prompt you for the rest of the command simply typing 'if' for example wont' complete until the shell sees the terminating 'fi' (bash). Commented Nov 3, 2011 at 13:36
3

The first line not ending with a '\' will execute it.

1
  • 8
    not true I keep getting > line after line and only Ctrl+C ends the horrible experience Commented Dec 20, 2021 at 4:27

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