Linux Bash shell shortcuts for common operations

Transfer: https://linuxtoy.org/archives/bash-shortcuts.html

 

Living in the Bash shell, memorize the shortcuts, will greatly improve your command-line operation efficiency.

Edit command

  • Ctrl + a: Move command line first
  • Ctrl + e: move the end of the command line
  • Ctrl + f: Press the characters forward (to the right)
  • Ctrl + b: After pressing the character move (to the left)
  • Alt + f: forward (to the right) by word
  • Alt + b: Press after the word move (to the left)
  • Ctrl + xx: move the cursor between the command and the beginning of the line
  • Ctrl + u: delete from the cursor to the first command line
  • Ctrl + k: Remove from the cursor to the end of the command line
  • Ctrl + w: remove prefix from the cursor to
  • Alt + d: Remove from the cursor to the suffix
  • Ctrl + d: delete the character at the cursor
  • Ctrl + h: delete the character before the cursor
  • Ctrl + y: stuck to the cursor
  • Alt + c: Change capitalized first letter words from the cursor
  • Alt + u: change from the cursor to all uppercase words
  • Alt + l: change from the cursor to the word all lowercase
  • Ctrl + t: exchange of characters before the cursor and
  • Alt + t: switching a word before the cursor and
  • Alt + Backspace: identical with Ctrl + w ~~ ~~ similar, some differences delimiter [rezilla correct thanks]

Re-execute the command

  • Ctrl + r: reverse search command history
  • Ctrl + g: Exit from the history search mode
  • Ctrl + p: the history of the previous command
  • Ctrl + n: the next command in history
  • Alt +:. The final parameter on the use of a command

control commands

  • Ctrl + l: clear screen
  • Ctrl + o: execution of the current command, and select a command on
  • Ctrl + s: stop screen output
  • Ctrl + q: Allow screen output
  • Ctrl + c: termination command
  • Ctrl + z: Suspend command

Bang (!) Command

  • !!: a command execution
  • ! Blah: blah beginning with the most recent execution of commands such as ls!
  • ! Blah: p: only print output without executing
  • !$:上一条命令的最后一个参数,与 Alt + . 相同
  • !$:p:打印输出 !$ 的内容
  • !*:上一条命令的所有参数
  • !*:p:打印输出 !* 的内容
  • ^blah:删除上一条命令中的 blah
  • ^blah^foo:将上一条命令中的 blah 替换为 foo
  • ^blah^foo^:将上一条命令中所有的 blah 都替换为 foo

_友情提示_:

  1、以上介绍的大多数 Bash 快捷键仅当在 emacs 编辑模式时有效,若你将 Bash 配置为 vi 编辑模式,那将遵循 vi 的按键绑定。Bash 默认为 emacs 编辑模式。如果你的 Bash 不在 emacs 编辑模式,可通过 set -o emacs 设置。

  2、^S、^Q、^C、^Z 是由终端设备处理的,可用 stty 命令设置。

Guess you like

Origin www.cnblogs.com/acm-icpcer/p/11595681.html
Recommended