Getting previous line in Bash after new command? -


in bash terminal, type command , realize needed sudo command. hit arrow previous command , backtrack beginning type sudo , enter.

is there way type sudo, press key pull down previous command after sudo?

thanks!

yes: can use "history expansion", , write !!:

$ foo bash: foo: command not found $ sudo !! sudo foo                             <-- prints out expanded command bash: sudo: command not found        <-- , runs 

Comments