How to find that command you entered in terminal

Yesterday I wanted to use again ffmpeg to make a screencast and couldn't remember exactly the complete command that suited my needs (video, audio format, etc.). I knew you had used it at some point but couldn't remember the entire command, with all its (endless) parameters. The solution? Find the way attempting in the historial de commands entered in the terminal.


The «history» command allows you to list the history of all the commands entered in the terminal. To filter the results we can combine it with the grep command as follows:

history | grep ffmpeg

This will list all the commands you have entered that contain the word "ffmpeg" somewhere. This is precisely what I was looking for.

Another very useful method is to press "Ctrl + R" and type the word you want to search for. The difference with the previous method is that it will search for the last command entered that contains that word, not all.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Computer Guardian said

    I am more of CTRL + R (I imagine that for convenience); As some of the colleagues who have commented indicate: just press it several times until we find the command we are looking for 😉

  2.   rizhu said

    Thanks for the information. Sometimes commands that seem too simple save your day. Especially when you have typed dozens and dozens of lines. Greetings from Zapatista lands in resistance.

  3.   yorsh said

    Thank you very much for your post, it helped me a lot, I just have one question, once I have the PID I needed, how can I execute that PID? thanks