Searching through your terminal buffer/historyJan 16th, 2012 | By admin | Category: Linux / Freebsd
For some reason I could have sworn this was as easy as pressing Ctrl-F but apparently it’s not.. Or maybe that’s something that was lost in the switch from Ubutntu to Debian.. Either way I needed a way to search a vast amount of terminal output quickly and easily and this is how I did it.
- Install screen – apt-get install screen
- run your commands from inside screen. If you need to search through 1000’s of lines of output you’ll probably need to adjust the output buffer size by adding this line to your ~/.screenrc: defscrollback 5000
- After you’ve run your command(s) and it/they’ve spit out line upon line of output you need to go into copy mode to start searching through.. You do this with C-a [ . I just did that to be a dick as I’ve seen it everywhere and no one bothers to explain what the bloody hell C-a is. It means Ctrl+a , shorthand for those people too lazy to type the trl in Ctrl I guess.. Anyways press Ctrl-a and then [ and then you’ll be in copy mode
- Search backwards by pressing ? and then typing in your search term. You can then press ‘n’ to go to the next instance
- Search forwards by pressing / and again n will go to the next instance
Easy peasy and way more 1337 than using ctrl-f .
PS – another really handy command in screen is Ctrl-a ? which brings up all the commands. Enjoy and happy searching