I am learning ansi escape codes with xterm. And according to this there is the following escape code:

CSI Ps SP A - Shift right Ps columns(s) (default = 1) (SR), ECMA-48.

Could anyone explain what is SP? Is it SPACE? I am asking as I tried it with space with the following command:

printf "\033[20 A"

But it didn't show any changes in ubuntu terminal.


2 Answers 2


The name is explained in the same source, i.e., here

It works in any mode of xterm:

  • add ISO and DEC controls useful for left/right scrolling.
     * This is from ISO 6429, not found in any of DEC's terminals.
  • probably not implemented (like 70-80% of xterm) in a given xterm-imitator. "ubuntu terminal" is on the low side of that range.
  • I see you are an expert in terminals and escape codes. Could you say, if there is a regex pattern that can detect any escape sequence code, for example ESC[...., ESC].... ESCN...? I need this regex pattern for ansi escape code parser. Currently I found this one stackoverflow.com/a/14693789/5057736 but it seems not to support all types.
    – Pavel_K
    Mar 17, 2022 at 8:10
  • For "most" (I didn't do C1 controls in that), see my answer. Handling all controls in a POSIX shell/sed script would be harder. Mar 17, 2022 at 9:40
  • Thank you very much for your help.
    – Pavel_K
    Mar 17, 2022 at 9:54

Yes, it is space. If you look at ECMA-48 standard, page 68, point 8.3.35, you have:

SR: CSI Pn 02/00 04/01

It use the old ASCII (and other encoding) notation, but 02/00 is 0x20 so equivalent of SP, if you are using ASCII encoding, and 04/01 is 0x41 (A if you are using ASCII encoding).

I think that function works only on some modes, but I'm not sure, and nothing in standard and in xterm site (that you linked) gives us hints.

  • Thank you for your answer. And could you explain what 02/00 and 04/01 is? I've never seen such encoding?
    – ThatsMe
    Mar 16, 2022 at 13:48
  • It is the old notation: number of column (from 0, in decimal numbers) and number of row (also from zero and in decimal numbers) of the character table. But you can just multiply the first number with 16 and add the second number, and you have the code. 07/15 is 127 (or 0x7F: 0xF is 15), so DELETE character. Mar 16, 2022 at 14:05
  • 1
    In other words, it’s hex, but not using the alphanumeric hex digits we use today, but rather writing each base-16 position as a two-digit decimal number.  02/00 is 0x20, 04/01 is 0x41, 07/15 is 0x7F, etc. Mar 16, 2022 at 14:35
  • @G-ManSays'ReinstateMonica': yes, but note the "two decimal number" is recent (, e.g. you see it in version 1991 of ECMA/ISO), older ECMA (and ASCII) just had 7/15, 4/1 (and they still refer sometime about columns and rows, e.g. topic of this question CSI final character must be in column 4 to column 7). Lucky they didn't pass to the octal numeration, and luckily Unicode used hexadecimal (since beginning). Mar 16, 2022 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .