Escape in bash

Source: Internet
Author: User
In bash, escape is a method for referencing a single character. the escape character (\ backslash) before a single character tells shell that this character does not need to be interpreted specially, and only serves as the literal meaning. however, in some commands and software packages such as echo and sed, escaping a character may lead to an opposite effect... in bash, escape is a method for referencing a single character. the escape character (\ backslash) before a single character tells shell that this character does not need to be interpreted specially, and only serves as the literal meaning. however, in some commands and software packages, such as echo and sed, escaping a character may lead to an opposite effect-because they may trigger the special meaning of that character. --- refer to some special escape sequences of abs: (use the help echo result as the blueprint, add some comments, others write, do not have to modify) \ a terminal ring (small machine does not support... same as \ x07, \ 07) \ B. move the cursor to the left. \ c disables automatic line feed at the end of a line, which is valid for echo, and invalid for printf \ e ESC escape sequence (see below, same as \ E, \ 033, \ x1b; which is the effect of pressing the ESC key) \ f form feed (move the cursor to the same column in the next line) \ n line feed (move the cursor to the beginning of the next line) \ r press enter (move the cursor back to the beginning of the line) \ t TAB (TAB Press effect ...) \ v vertical tab (same as \ f) \ x00 sixteen mechanism number value (two hexadecimal numbers of [0-9a-fA-F ). \ backslash... \ 000 octal values (starting with a number, up to 3 [0-7] digits) PS escape sequence (prompt symbol, bash prompt, not verified ): (from English http://www.linuxselfhelp.com/how ... H-Prompt-HOWTO.html, translation for reference) \ a bell \ d Date, format: "Weekday Month Date", ("Tue May 26") \ e ESC escape sequence. the first part of the \ h host name. (froms) \ H complete host name. (froms.vuuvsoft.com) \ n Newline \ r press enter \ s shell name. obtain by path. for example,/usr/bin/bash --> "bash" \ t time, in the format of HH: MM: SS 24-hour. ("23:01:01") \ T time, in the format of HH: MM: SS 12-hour. ("11:01:01") \ @ 12-hour username with am/pm \ u. ("root") \ v bash version ("2.00") \ V bash version and patch level ("2.00.0") \ w current working directory full path ("/home/from S ") \ W current working directory name (" froms ")\! Position of the current command in the history buffer \ # command number (it will be accumulated every time you type the content) \ $ if you are root, "#" is displayed; otherwise, "$ ". \ nnn octal numbers \ backslash \ [this sequence should appear before the character sequence without moving the cursor (such as the color escape sequence. it enables bash to correctly calculate the line feed. \] This sequence should appear after the non-printable character sequence. (\ [\ e [32; 47m \]) (inaction Note: Of course, you can also use the command to display the time and date: PS1 = "$ (date + % x-% X)") (the following content is from the result of man console_codes. the translation has been modified and some sequences that cannot be used on the server are deleted .) ESC escape sequence: c resets the terminal. d. Form Feed (vertical tab ). e. wrap. h. set the current column as a tab. (not verified) M flipped line feed, page feed up (Reverse linefeed ). 7. store the current status (cursor coordinates, attributes ). 8. restore the last Storage setting [(see below) #8. screen calibration test-fill the screen with E. for example, printf "\ e #8" ESC [escape sequence: Move the cursor up A specified row. b. move the cursor down the specified row. c. move the cursor to the right of the specified column. \ e [3C right shift 3 columns D cursor left shift specified column. G move the cursor to the specified column in the current row. H move the cursor to the specified row and column (the start count of the row and column is 1, and the start count of tput cup is 0 ). \ e [y; xH y = 3; x = 5 The Fifth Column in the third row. j. delete the content (from the current cursor to the end by default ). \ e [1J: delete content from start to cursor. \ e [2J: clear the entire screen. k. delete the row (from the current cursor to the end of the row by default ). \ e [1 K: delete content from the beginning of the row to the current cursor. \ e [2 K: delete the entire row. d move the cursor to the current column and specify the row f as \ H. h setting mode (see below ). l reset mode (see below ). m sets attributes (see below ). n Status Report (see below ). r sets the scroll range. the parameters are the first and last rows. (It seems that it cannot be used ...) s stores the cursor position. u restores the cursor position. set graphic properties: \ e [ <属性数值> M sets the Display attribute. you can set one or more attributes for the same sequence, separated. special effect Code: 0 clear all properties 1 highlight (and bold, but unfortunately the small machine is not bold) 2 dark colors (Display in general brightness, not supported by the small machine) 4 underline 5 flashing (small machine flashing frequency is too low, useless) 7 reverse display. 8 Hide (a paragraph is not displayed, not supported by a midrange computer) 22 normal brightness 24 turn off underline 25 do not flash 27 do not reverse display color code prefix: 3: foreground 9: highlight foreground 4: background 10: highlight background color code suffix (highlight effect): 0 black (dark gray) 1 red (bright red) 2 Green (bright green) 3 Brown (yellow) 4 blue (light blue) 5 Purple (light purple) (this cannot be seen) 6 Green (bright green) 7 light gray (white) 9 default color (limited to 3, 4 prefix) example: green foreground, bright blue background, underline. 0 indicates clearing all previously set properties. \ e [0; 32; 106; 4 m after printing a piece of content, do not underline \ e [24 m again want to reverse display (that is, the green background) \ E [7 m. how can we remove the reverse display? Status Report: \ e [5n device Status Report (DSR): responds with \ e [0n (prepared by the terminal ). \ e [6n cursor position report (CPR): responds with \ e [y; xR. Here, x, y indicates the cursor position. setting mode (replacing the last h with l is resetting mode) \ e [? 5 h Full screen reverse display. \ e [? 25 h Terminal cursor display
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.