For example, in bash I can type !xyz
which will run the last command I typed beginning with xyz
.
How can I bring up the last command I typed beginning with xyz
but without executing it?
e.g so I can change parameters before execution....
For example, in bash I can type !xyz
which will run the last command I typed beginning with xyz
.
How can I bring up the last command I typed beginning with xyz
but without executing it?
e.g so I can change parameters before execution....
You can do it like this: On the command prompt press Ctrl+r and then type the command you want to recall, in your case
xyz
. This will show you the complete command without executing it.Try
!xyz:p
; it will recall the command to the top of history without executing it, so eg up-arrow can immediately access it for interactive editing.As an aside, I make a practice of doing this when recalling commands with a regexp that could conceivably dig up something damaging, ever since a hasty
!r
, intended to recall the most recentrsync ...
command, pulled back and executed anrm *
that had been pushed to the stack more recently than the rsync.Execute the following command. It will echo the last executed command. you can copy and edit the command. This command tested in debian.
history |tail -2 | grep -v history | cut -d ' ' -f4-
Or Press and hold ctrl+R and type the starting letter of your last command. It will list the commands you executed previously based on your input. Once it shows desired command, just press right arrow in order to select that command.
If reverse history search failed, do anything of:
Or: