Move by word in bash

2634
Simon Sheehan

In bash, you can move to the beginning of the line with CTRL+A, and the end with CTRL+E. How can I move forward and backward by word?

6
`man bash` und lies dann die Dokumente im Abschnitt READLINE. Kaleb Pederson vor 13 Jahren 1
Eine weitere praktische Referenz für Bash-Tastaturkürzel: https://en.wikipedia.org/wiki/Bash_(Unix_shell)#Keyboard_shortcuts Amanda vor 11 Jahren 0

3 Antworten auf die Frage

12
R Samuel Klatchko

With emacs bindings:

Meta-B moves back a word and Meta-F moves forward a word.

Ctrl-B moved back a character and Ctrl-F moves forward a character.

So B vs F is backwards vs forward and Meta vs Ctrl is word vs character.

The exact mapping of Meta may vary between keyboards. Try holding down Alt while pressing the other key; if that doesn't work, press and release Esc and then press the other key.

1
neo730

use alt+b for backward and alt+f for forward movement by a word.

1
gavenkoa

Einfügen ~/.inputrc:

# Strg + Links / Rechts, um sich durch ganze Wörter zu bewegen. "\ e [1; 5C": Vorwärtswort "\ e [1; 5D": Rückwärtswort # Gleiches Drücken von Shift. "\ e [1; 6C": Vorwärtswort "\ e [1; 6D": Rückwärtswort