What does this command do?
!g++ For the history command:
!12 It runs command #12 of the history, but what about g++, or another:
!cat filename What does this command do?
!g++ For the history command:
!12 It runs command #12 of the history, but what about g++, or another:
!cat filename See the Bash manual, "Event Designators":
!stringRefer to the most recent command preceding the current position in the history list starting with
string.
This means that !g++ runs the last command that began with g++, calling the GNU C++ compiler:
$ g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran ... (g++ does its job here) ... $ vim test ... (other commands) ... $ !g++ g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran <-- same command as before !cat filename, on the other hands, doesn't make a lot of sense as it's already a complete command. Unless there was a super complicated pipe after that command the last time, of course, which the event designator would then repeat.