You input command in your linux terminal which is very long and hard to remember. It is needed to input the command again to the terminal. You find...
For further actions, you may consider blocking this person and/or reporting abuse
If you know the command you're trying to repeat, then
!<starting-string>
is great. Similarly, if you know the command you're trying to repeat, but you need to modify it,!<starting-string>:s/<SEARCH>/<REPLACE>
or even!<starting-string>:gs/<SEARCH>/<REPLACE>
are freaking awesome.Note: This type of advanced command-history usage works in BASH and CSH-derived shells. Dunno about other shell-families.
Big fan of using history, I'd be lost if I didn't have it. My personal way of accessing it on Macs is by using Ctrl + R and that let's you do pretty much the same thing as the grep method and you don't have to do the second line to execute the expression. Give it a try!
If your
.bash_history
file is large (as mine is), piping the output of thehistory
command togrep
can be very slow. For example, my current history file is over 100k lines, and it takes 10+ seconds (on my machine) for the command to complete.A faster method is to simply grep the file directly, which takes under 1 second:
Or, even better, set up a function to do this:
then:
Or if you use Ripgrep (As I do):
super useful,thanks for sharing