Bash history between two points in time

Viewed 508

I would like to do something like

history 2960-2966

with the expectation of this kind of output:

2960  2013-12-09 20:59:35 bundle update
2961  2013-12-09 21:00:08 git st
2962  2013-12-09 21:00:12 git add .
2963  2013-12-09 21:01:19 git st
2964  2013-12-09 21:01:43 git log
2965  2013-12-09 21:02:45 git st
2966  2013-12-09 21:02:57 git reset HEAD Gemfile.lock

Is this possible in the bash shell?

UPDATE: My question is about seeing those seven history rows, not the dates, per se; it just happens that I have a HISTTIMEFORMAT directive in my .bash_profile to give the date and time stamp. If I were to remove it then I would wish history 2960-2966, or something, to generate this output:

2960  bundle update
2961  git st
2962  git add .
2963  git st
2964  git log
2965  git st
2966  git reset HEAD Gemfile.lock

I want the desired history rows to be displayed, preferably with any customization I've specified in .bash_profile.

Why would I want this? A very simple use case is: I do something like history | grep 'bundle update' get a decent result, then want to see some history from that point plus a few lines farther along, or maybe the history bracketing that point.

7 Answers
Related