I’ve been checking my server for the status of wget that I’ve left running. To my surprise, it was halted. Frustrated by the long url which I’ve entered previously, I go for some bash magic research.
I found out that bash has a neat feature which allows us to retrieve what’s been entered previously, and not just by pressing the up arrow on the keyboard. It can be done in multiple ways, but I prefer the generic one which utilizes grep command.
In my case, to find previous wget command entry line:
history | grep -i "wget"
Nice and simple. The -i following the grep is for case insensitive search. This command will results in a list of command history. Pick the number of history that we are interested in which is on the leftmost column, and append it to a !, like so:
!1999
There you go, the command will be executed instantly! Congrats.
If it happens that you want to get the command and modify it, append :p to the recall line
!1999:p
press Enter and press up arrow. Neat.