Say I would like to recall and run a command (eg)

wget https://go.skype.com/skypeforlinux-64.deb

that I already use a day ago. I used the instruction

history | grep skype

which example output is

 1584  sudo apt-get purge skypeforlinux 
 1585  sudo snap install skype 
 1824  cd skype/
 1829  wget https://go.skype.com/skypeforlinux-64.deb
 2001  history | grep skype

How to extend the piping to run directly the process 1829 (without writing a new command !1829)?

  • 2
    How would you proceed to select the right entry if there are more than one matches in the history, as in your example?
    – AdminBee
    Apr 8 '20 at 14:35
  • If I manage to tighten the output say with | grep "go.skype.com" or something similar. What would be the next steps?
    – Many
    Apr 8 '20 at 14:44

Instead of "greping" the history you could just use the reverse-search.

If you press [ctrl] + [r] (both keys at the same time) you will search backwards in your command-history.

So if you want to re-execute (for instance)

wget https://go.skype.com/skypeforlinux-64.deb

you could just press [ctrl] + [r], type in skype and then it should already display the command.

If this wasn't the last command you can cycle through the history pressing [ctrl] + [r] again.

  • Hum! It is a way to fix my problem. Great!!!!
    – Many
    Apr 8 '20 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.