Tuesday, April 5, 2011

OSX - Command Line History

If you’re like me you run a few commands from the Terminal, and trying to remember an exact command you executed can be hard.

Well, you can query your command line history to find previous commands by using the following syntax:

    history |grep "search string"

A curious aspect is that bash remembers this query as well, so you never get a null result, even a rubbish search gives you itself:

    $ history | grep "fjkskjfvkjf"
    140 history | grep "fjkskjfvkjf"

1 comment:

previouslysilent said...

can you not hit CTRL-R and do an incremental search from a partially typed string?