geekdoc-python-zh/docs/pythonland/68.md

17 lines
995 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用 Bash 历史记录
> 原文:[https://python.land/the-unix-shell/using-the-bash-history](https://python.land/the-unix-shell/using-the-bash-history)
现在你知道了所有这些令人敬畏的命令,但是下周你会发现你已经忘记了它们。幸运的是,这里也有工具可以帮助我们!
您可以**使用向上和向下键来滚动浏览先前键入的命令**。这还不是全部。我在下表中列出了一些基于历史的省时方法:
| 命令 | 说明 |
| --- | --- |
| `history n` | 查看历史记录中最多`n`行 |
| `!!` | 重复最后一个命令 |
| `!n` | 重复历史中的命令编号 n |
| `!cd` | 重新运行您键入的最后一个命令在本例中从“cd”开始 |
| `!*` | 替换上一个命令中的参数 |
也许使用终端历史最有效的方法是通过搜索它。**点击`control + r`获得与您的历史记录中的文本相匹配的搜索提示。**只要开始输入之前命令的任何部分,你就能找到它!