ANSI C quoting
ANSI-C quoting allows for backslash-escaped characters to be interpreted according to the ANSI C standard, enabling special characters like newlines and tabs to be represented within strings. This is done using the syntax $‘string’, where escape sequences are processed accordingly.
$'string'
How It Works
When using ANSI-C quoting, the following escape sequences are processed:
- Newline: `\
- Tab: \t
- Backslash: \
- Octal values: \nnn (where nnn is one to three octal digits)
- Hexadecimal values: \xnn (where nn is one to three hexadecimal digits)
Examples
Here’s a table illustrating how ANSI-C quoting works:
Command Result
echo $‘Hello\nWorld’ Prints: Hello (new line) World echo $‘Tab:\tIndented’ Prints: Tab: (tab space) Indented echo $‘Quote: ’ Prints: Quote: ’ `