How to echo `single quote` when using single quote to wrap special characters in shell?

The tutorial is wrong.

POSIX says:

A single-quote cannot occur within single-quotes.

Here's some alternatives:

echo $'It\'s Shell Programming'  # ksh, bash, and zsh only, does not expand variables
echo "It's Shell Programming"   # all shells, expands variables
echo 'It'\''s Shell Programming' # all shells, single quote is outside the quotes
echo 'It'"'"'s Shell Programming' # all shells, single quote is inside double quotes

Further reading: Quotes - Greg's Wiki

Tags:

Shell

Quoting