This is the proper way to use grep. You do not need to use cat at all. This method works well and is one command, not two piping together. [email protected]:~/Documents$ grep apt-get ../.bash_history sudo apt-get update sudo apt-get install me-tv sudo apt-get update && sudo apt-get install xvst apt-get moo apt-get [email protected]:~/Documents$ grep apt-get ../.bash_history …