Question: What happens when you run the following file as a shell script? What is going on?
echo 'I don't know'

Answer: The apostrophe in "don't" actually terminates the quoted part of the command, so "t", space, "know" are all actually outside of the quotes. This is fine. But then the single-quote at the end (which is the same character -- apostrophe and single-quote have the same code in the ASCII character code) starts another quoted part, and then the file ends not long after, so this is an error. You have to end the quoted parts with a closing quote.

Question: How about this?

echo 'I don't know much, but at least I ain't lost!'

Answer: The apostrophe in "don't" terminates the quoted part of the line; but then the apostrophe in "ain't" starts it again. Then the apostrophe at the end terminates the second quoted part. So the quotes match, although not in the way the author of that line probably intended. Also, they are not literal apostrophes for output purposes; if you look at the output you will see it is missing the apostrophes.


(press 'back' in your web browser to get back to where you were in the exam)