Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
Shell exclamation mark command

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
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

See the Bash manual, "Event Designators":

!string

Refer 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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!