Bash How to Echo Quotes
In this case, it is essential to put a backslash. Backslash will focus on character followed by a sign with a backslash. The following characters depose functions of the meta tag.
If you want to echo single quotes, you can to:
echo Single quote: \'
Output: Single quote: ‘
If you want to echo double quote, you can do:
echo Double quote: \"
Output: Double quote: ”
If you want to quote a single quote in double-quotes:
echo "Single quote in double-quotes: '"
Output: Single quote in double-quotes: ‘
If you want to quotes double quotes in double-quotes:
echo "Double quote in double-quotes \""
Output: Double quote in double quotes ”
There are 2 kinds of quoting: weak (“) and strong (‘). Using weak quoting there is no special meanings of:
- pathname expansion
- process substitution
- single-quotes
- characters for pattern matching
If we use strong quoting, nothing is interpreted, except a single quote. Examples:
echo "Path to your shell is: $SHELL" echo 'Path to your shell is: $SHELL'
Output: Path to your shell is: /bin/bash
Path to your shell is: $SHELL