linux - 在每次登录到 shell 时打印 session 中最后 10 个命令的历史记录

标签 linux bash ubuntu input-history

我正在尝试在每次登录时打印最后一个 session 的最后 10 个命令,在
bash.bashrc。我写了这个:

echo "$(history 10)"
但它没有打印任何东西。

最佳答案

Bash 历史仅在 .bashrc 之后从文件中加载已完成。
您可以强制加载历史记录,然后通过将以下内容添加到您的 .bashrc 来输出您想要的内容。文件:

history -r
history 10

关于linux - 在每次登录到 shell 时打印 session 中最后 10 个命令的历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70435133/

相关文章:

Qt Creator 在 Ubuntu Virtualbox 中挂起

c++ - 找不到库,即使它在搜索路径上

bash - 将 bash 脚本转换为 Python - 如何处理 heredocs?

bash - gpg — 仅将内容直接解密到 stout

java - 使用 java 执行 shell 命令时与进程通信

linux - 为什么在 Unix 的 crontab 条目中包含 ". ./.profile"?

bash - 如何按特定列对 csv 进行排序

java - 列出 httpd 和 Tomcat 之间的 AJP 连接

linux - Mongodb - 如何重启你刚刚在 Linux 中杀死的 mongodb?

linux - 有哪些 Linux 发行版可以在不修改系统的情况下编译 Xen 源代码?