From what I remember the “!” command in bash is to re-execute a command.
One way of doing this is to run the command history, then running the appropriate entry, !2028 to repeat command 2,028 for example.
What I used to do much more commonly was “repeat last command starting with …” to just repeat the last thing I ran. For example !vi would re-run the last command starting with vi.
I just tried this, and it did not work as expected. It ran a different command, not the last one. Has something changed? Is this expected behaviour, or a bug? Why did it run a different command instead of the last one?
Terminal Output:
($) /mnt/Storage/win10-share: vi ~/.mountShares.sh
($) /mnt/Storage/win10-share: !vi
vi .moveApps.sh
Seems to work fine here. Have you checked the entries in the history to see what the latest entries are? Did you run commands in another bash session in parallel?
Interesting. I do have multiple terminals running, but I’m not running the same commands on different terminals. I haven’t edited that .moveApps.sh file today, so I don’t know why it would open that one.