ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20210207]bash history小技巧.txt

[20210207]bash history小技巧.txt

原创 Linux操作系统 作者:lfree 时间:2021-02-07 17:15:58 1 删除 编辑

[20210207]bash history小技巧.txt

--//我经常在tmux下工作,在重新调用history命令缓存存在一些问题,做一个记录.
--//通过例子演示:

--//窗口1:
$ qqqqqqqqqqqqq

--//窗口2:
$ wwwwwwwwwwwww

--//窗口1:
$ eeeeeeeeeeeee

--//窗口2:
$ rrrrrrrrrrrrr

--//这个时候如果在窗口1调用窗口2执行的命令无法实现的,通过ctrl+R.
--//实际上就是两个history缓存无法共享.以前我一般通过copy and paste解决.或者关闭退出窗口2.
--//实际上只要执行history -a追加到histfile文件中.另外的窗口执行history -r就可以实现.

--//窗口2:
$ history -a

--//窗口1:
$ history -a
$ history |tail -20
....
 6473  2021-02-07 10:04:57 = wwwwwwwwwwwww
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6474  2021-02-07 10:05:17 = rrrrrrrrrrrrr
 6475  2021-02-07 10:10:00 = history -a
 6477  2021-02-07 10:02:39 = history -a
 6478  2021-02-07 10:03:17 = history
 6479  2021-02-07 10:04:50 = qqqqqqqqqqqqq
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 6480  2021-02-07 10:05:11 = eeeeeeeeeeeee
 6482  2021-02-07 10:10:29 = history
 6483  2021-02-07 10:10:39 = history | tail
 6484  2021-02-07 10:12:12 = history |tail -20

--//注意前面的时间顺序是乱的.这样在窗口1就可以通过ctrl+r调用窗口2曾经执行过的命令.
--//我也尝试将HISTTIMEFORMAT export HISTTIMEFORMAT="$(tty) %F %T =" ,但是没有用.
--//-a仅仅保存时间信息.没有tty命令的信息.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2756677/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4014
  • 访问量
    7990957