Bash uses exclamation marks for history expansions, as explained in the answers to this question (e.g. sudo !!
runs the previous command-line with sudo
). However, I can't find anywhere that explains what running the following command (i.e. a single exclamation mark) does:
!
It appears to print nothing and exit with 1, but I'm not sure why it does that. I've looked online and in the Bash man page, but can't find anything, apart from the fact that it's a "reserved word" – but so is }
, and running this:
}
prints an error:
bash: syntax error near unexpected token `}'
!
indicates the "start" of a history expansion expression. – jordanm Apr 14 '18 at 21:02