Here is an example code from a book I need to type on terminal

> db.users.update( {username: "smith"},
{ $set: {favorites:
   {
     cities: ["Chicago", "Cheyenne"],
     movies: ["Casablanca", "The Sting"]
} }
})

How to write this? as soon as I write first line ending with comma (,) and press enter to goto next line it executes the command. Can I format my command like the above?

link|improve this question

65% accept rate
feedback

1 Answer

up vote 1 down vote accepted

You can usually escape line breaks using a \. So just type that before you press enter. It probably depends on the program (e.g. shell) you're running though. In bash you get a continuation prompt (>) and can continue typing your command.

$ l\
> s -la
total 88
drwx------+  4 danielbeck  staff    136 10 Jan 08:13 .
drwxr-xr-x  67 danielbeck  staff   2278  9 Jan 23:37 ..
-rw-------@  1 danielbeck  staff  43012 10 Jan 08:13 .DS_Store

In many cases, you can skip newlines when typing in code from a book or other source. Your code snippet looks like it might work without newlines, and is just formatted like that for readability.

link|improve this answer
1  
The sql code syntax looks fine. It should be acepted on sql server prompt. End it with a semicolon. What error message are you getting? – daya Jan 10 at 7:36
feedback

Your Answer

 
or
required, but never shown

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