Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Yep, I do `history | grep "<whatever>"` all the time..

I should probably make it a function now that I think about it.



sort by: page size:

I usually do a `history | grep something | grep somethingelse` to find stuff in my history

I just grep through my bash history ;)

I do the same, except instead of `history` i grep the .bash_history file :-P

(i almost always need it for stuff i typed several sessions ago)


I alias "history | grep" to "hrep" and I'd bet it is one of my top 3-5 commands.

As someone above said,

history | grep -i "whatever I want to remember"


history | grep <thing>

I use a number of tools and I've often forgotten an individual command, or when I'm using tools like curl or docker that have a long single line command that I know I can't remember.


Also, another way to find past commands you run `history | grep <whatever-you-are-looking-for>` and works wonders; or as other users have mentioned, Ctrl-R works too.

That's pretty much it. I used to have to use quite a few different shells, so `<CTRL> + r` wasn't always available, but `history | grep` usually was. Once I'd got in the the habit of using `history | grep` I found that I liked the extra context provided by seeing a group of commands with a few variations between the lines. So often it helps jog my memory of what parameters I'll need to change before using it.

I do the same thing, and have a couple of commands set up to run grep over the last day, week, month, or ever in my history. I don't use my full history every day, but it's something worth keeping around.

shell command line history roll your own: fn history {grep '^term%' /mnt/wsys/text|sed -e 's/^term%//'}

oh yes that is so elegant...


I usually just do `history | grep ...` instead; it's faster and more flexible than trying to flip through Ctrl+R matches.

That said, I did just install the history-search-backward and history-search-forward hooks in inputrc, and I can already tell I'll love these.


Just as useful,

history | grep pattern

With all the useful grep abilities (like peaking at commands before or after the given pattern).


same here - my cheatsheet is `history | grep`

history | grep <command halfway remember using>

It's funny how personal workflows can be. I do the history|grep thing too, but never felt the need to automate it further. It's a relatively rare thing (maybe once a day), used when I know I did something specific in the past but forget a detail or two.

Instead, I generally drop little shell scripts around my work area for specific tasks. Working on iterating a build/install to chase a specific bug? Stuff it into a little script. Writing a find command to munge a bunch of files with xargs or -exec or whatnot and realize I'm into the third line or editting? Stop and echo it into a file, then finish it in emacs.

The idea of doing all that junk and then relying on the bash history file (instead of, y'know, the actual filesystem) to store it for me seems weird.


Nice! I’ve been at this game for a while and ctrl-r must have slipped right past me till now. I’ve regularly do ‘history | grep ___’ but ctrl-r looks like a far better solution.

I also use `history | vim -` to search through the history in the context of other things I was attempting to do. Say, if I try some command and it does not work, chances are it's not the first time and I have the correct version on the line bellow :)

As someone who massively use Ctrl+r and history|grep, I don't get it. Can you elaborate, with examples if possible?

Yeah I heard of people grepping their history file. Ctrl+R is so much faster.
next

Legal | privacy