当前位置:首页 > linux > 正文

linux搜索历史命令(linux的top命令)

  • linux
  • 2024-03-16 05:12:21
  • 2209
Linux 搜索历史命令
语法:
bash
history [options] [string]
要素:
选项:
- -c:清除历史记录。
- -d [number]:删除指定编号的历史命令。
- -f [file]:从指定文件读取或写入历史记录。
- -n [number]:显示指定数量的最近历史命令。
- -r:反向显示历史记录。
- -s [string]:在历史记录中搜索指定的字符串。
参数:
- string:在历史记录中搜索的字符串。
示例:
- 显示最近 10 条历史命令:
bash
history 10
- 搜索包含 "ls" 的历史命令:
bash
history | grep ls
- 删除编号为 24 的历史命令:
bash
history -d 24
- 从文件读取历史记录:
bash
history -f ~/.bash_history
- 将历史记录写入文件:
bash
history -f ~/.bash_history_new