How to get Bash shell history range

Posted by Aniti on Super User See other posts from Super User or by Aniti
Published on 2010-10-04T11:12:53Z Indexed on 2012/06/18 3:19 UTC
Read the original article Hit count: 266

Filed under:
|
|
|

How can I get/filter history entries in a specific range?

I have a large history file and frequently use

history | grep somecommand

Now, my memory is pretty bad and I also want to see what else I did around the time I entered the command.

For now I do this: get match, say 4992 somecommand, then I do

history | grep 49[0-9][0-9]

this is usually good enough, but I would much rather do it more precisely, that is see commands from 4972 to 5012, that is 20 commands before and 20 after.

I am wondering if there is an easier way? I suspect, a custom script is in order, but perhaps someone else has done something similar before.

© Super User or respective owner

Related posts about linux

Related posts about bash