To expand on it a bit, think of quoting in shell scripting as a toggle switch. One instance turns on escaping, and the next turns it off. They're read sequentially*, not as enclosures (though they generally act as if they were).
Also recognize how the two quote types work together. The ', or hard quote, will escape everything after it until it hits another '. The ", or soft quote, will escape everything except $, \, and `, until it hits the next ". This allows variable expansion and embedded commands to work inside them.
Note that the hard quote is escaped inside the soft quotes and vice-versa, which is why colucix's code above works. Note also that since \ is also unescaped inside of soft quotes, it allows you to still escape $ and `, and even other "s if necessary. This doesn't work inside hard quotes, since everything is already escaped.
*There are a few exceptions. Quotes inside of subshells, embedded commands, and parameter substitutions, for example, are considered separate sequences. But they behave normally inside their respective nestings.
Last edited by David the H.; 03-11-2010 at 11:47 AM.
Reason: minor rewording