2

man bash says:

backward-delete-char (Rubout)

Delete the character behind the cursor. When given a numeric argument, save the deleted text on the kill ring.

Is Rubout just Delete key on keyboard? Because it has the same function as bash describes backward-delete-char.

But when I try:

backward-kill-line (C-x Rubout)

Kill backward to the beginning of the line.

Consider following case:

$ testa testb testc testd

assume the point is on testc's t, now I press Control+x then press Delete key on keyboard. The result is:

$ testa testb [3~testc testd

I just can't understand it, am I missing something?

  • 3
    <kbd>Rubout</kbd> is not <kbd>Delete</kbd> key, it is <kbd>Backspace</kbd> – Costas Feb 27 '17 at 13:17
5

There are three concepts to be clarified in the simple description of:

backward-delete-char (Rubout)

  • Keys
    There is a key called Delete, one which you are using in your examples.
    That key erase "the next character".
    If the line contains test1 and the cursor (the blinking indicator) is over the letter s, Delete will erase the s.
    In contrast, there is a key called Backspace, which, in exactly the same conditions will erase the letter e. That is the letter which precede the cursor.

    That Backspace key is being described by "backward-delete-char (Rubout)" in the bash manual.

    That key, obviously "Delete the character behind the cursor".

  • Numeric Argument
    To give it a "numeric argument" you need to press Alt-2, for example, which will place a 2 as an argument to the next command (or key).

    Again, if the word test is written in the line, and the cursor is at the s, press Alt-2 and then the Backspace. That will Back erase two characters, the te in the word test.

  • The kill ring. When something is erased, in most cases, is placed in a kill ring.
    To get what is inside the "kill ring" use ctrl-y.

    If you erase several characters, with alt-3-Backspace, those characters will reapear using ctrl-y.

    In Detail:

    If you use an argument to the command Backspace, you will erase as many characters as the argument say "before" the current position of the cursor.

    If there is this string at the command prompt:

    $ testa testb testc
    

    And the cursor is under the letter "b", an Alt-3-Backspace will remove the characters "est":

    $ testa tb testc
    

    Those characters will be printed back with ctrl-y

Now, the:

backward-kill-line (C-x Rubout)

Means to press: ctrl-x Backspace

Which will place the whole line "before the cursor" in the kill ring.

And, the keys: ctrl-x Delete have no action defined for them, which will make the equivalent ANSI code to be printed:

[3~

In your terminal. That could be changed in the ~/.inputrc for the readline library which bash use. But that is outside the scope for this answer, I believe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.