Placement of comma before quotation mark

What is the rule for comma placement before a quotation mark? When should the comma go before and when should it go after the quotation mark?


Solution 1:

In American literature and university courses, the method for introducing a quotation is the same as the British English style: the comma is placed after the last word that introduces the quotation.

Martin said, “Who brought that dog?”

As for the closing quotation mark, American English prefers the comma to be placed before the ending quotation mark.

In her notebook, Sheila wrote that the sun was “beet-red,” but after the game she had seen it “disappear over the bleachers.”

Solution 2:

The above mentioned rules are often broken in the context of computer programming. It does not always result from the fact that a poster doesn't know the rules, but it would just be misleading, eg.

After that you need to issue "find . -name *.jpg {};."

In the above example the last full stop is NOT a part of the command and, if typed as such, would lead to errors.