escaped.sh

来自「Shall高级编程」· Shell 代码 · 共 83 行

SH
83
字号
#!/bin/bash# escaped.sh: escaped charactersecho; echo# Escaping a newline.# ------------------echo ""echo "This will printas two lines."# This will print# as two lines.echo "This will print \as one line."# This will print as one line.echo; echoecho "============="echo "\v\v\v\v"      # Prints \v\v\v\v literally.# Use the -e option with 'echo' to print escaped characters.echo "============="echo "VERTICAL TABS"echo -e "\v\v\v\v"   # Prints 4 vertical tabs.echo "=============="echo "QUOTATION MARK"echo -e "\042"       # Prints " (quote, octal ASCII character 42).echo "=============="# The $'\X' construct makes the -e option unnecessary.echo; echo "NEWLINE AND BEEP"echo $'\n'           # Newline.echo $'\a'           # Alert (beep).echo "==============="echo "QUOTATION MARKS"# Version 2 and later of Bash permits using the $'\nnn' construct.# Note that in this case, '\nnn' is an octal value.echo $'\t \042 \t'   # Quote (") framed by tabs.# It also works with hexadecimal values, in an $'\xhhh' construct.echo $'\t \x22 \t'  # Quote (") framed by tabs.# Thank you, Greg Keraunen, for pointing this out.# Earlier Bash versions allowed '\x022'.echo "==============="echo# Assigning ASCII characters to a variable.# ----------------------------------------quote=$'\042'        # " assigned to a variable.echo "$quote This is a quoted string, $quote and this lies outside the quotes."echo# Concatenating ASCII chars in a variable.triple_underline=$'\137\137\137'  # 137 is octal ASCII code for '_'.echo "$triple_underline UNDERLINE $triple_underline"echoABC=$'\101\102\103\010'           # 101, 102, 103 are octal A, B, C.echo $ABCecho; echoescape=$'\033'                    # 033 is octal for escape.echo "\"escape\" echoes as $escape"#                                   no visible output.echo; echoexit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?