escape sequence
A backslash followed by a character that together stand for something hard to type directly, such as \n for a line break.
In more detail
Escape sequences let text contain characters such as line breaks, tabs or quote marks that would otherwise end or break the text. Common ones are \n for a newline, \t for a tab and \\ for a real backslash. Which sequences are understood depends on the language, tool and quoting, so the same text can print differently in different places.
Examples
content: "enabled\n" in a copy task writes a file ending in a real line break.printf 'one\ttwo\n'echo $'tab:\there'route="/say \"hi\""Prometheus label values must escape " \ and newline.print("one\ntwo")Related terms
- YAML — A human-friendly text format for configuration, where indentation shows structure.
- whitespace — Characters that show as blank space, such as spaces, tabs and line breaks.
- printf — The command that prints text according to a format string, such as printf '%s\n' "$name".
- newline — The invisible character that ends a line of text, written \n in most programming languages.
- ANSI-C quoting — The $'...' quoting form, which works like single quotes but turns escape sequences such as \n and \' into the real characters.
- Prometheus exposition format — The plain-text format a metrics page uses: one sample per line with name, optional labels in braces and a value, plus comment lines for help text and type.
- metric label — A name and value attached to a metric, such as status="200", that splits one metric into separate series you can compare.
- string — A sequence of characters, that is, a piece of text.
- delimiter — The quote marks that mark where a string literal begins and ends; Python accepts either single or double quotes.
Taught in
- Writing Your First Playbook — Ansible Configuration Management at Scale
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- The Field Separator, And Reading Lines Safely — Bash Scripting & Command Line Automation
- Arrays, And Why Dollar At Is Not Dollar Star — Bash Scripting & Command Line Automation
- Reshaping Text: cut, sort, uniq, tr, sed, awk — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- The Prometheus Exposition Format — Full-Stack Observability: Metrics, Tracing & Logging
- The Print Function And String Literals — Hands-on Python: Complete Video Course & Book
- The Print Function Keyword End — Hands-on Python: Complete Video Course & Book
- Chapter One In One Sitting — Hands-on Python: Complete Video Course & Book
- Compound Boolean Expressions — Hands-on Python: Complete Video Course & Book
- Paths And Files The Modern Way — Hands-on Python: Complete Video Course & Book
- Thirty Questions, One Sneaky Print — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Interpreter, Compiler, And What Counts As Syntax — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Print, Input And The Casts Between — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Strings: Escapes, Slices And Methods — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Try, Except, Else And Finally — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Import Variants, dir() And sys.path — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Your Own Modules And Packages — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Modules Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Characters As Numbers — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- String Methods The Exam Picks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Strings Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Introspection: hasattr, __name__, __module__ And __bases__ — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems
References
- YAML 1.2.2 specification: escaped characters
- Bash Reference Manual: ANSI-C Quoting
- POSIX printf utility
- Prometheus: exposition formats
- Lexical analysis: escape sequences