Besides the convenience of the commands in the first part of this chapter, there is another type of time-saver, which does not necessarily need to be discussed in the context of shell scripting, but is still such a great asset that we'd feel bad if we did not share it with you: command-line shortcuts.
Exclamations marks are normally used to give text some emphasis, but under Bash they are actually a shell
keyword:
reader@ubuntu:~$ type -a ! ! is a shell keyword
While the term "shell keyword" does not really give us a great indication of what it does, there are multiple things we can accomplish with the exclamation mark. One we have already seen: if we want to negate a test
, we can supply the exclamation mark within the check. If you'd like to verify this on your Terminal, try the following with either true
or false
:
reader@ubuntu:~$ true reader@ubuntu:~$ echo $? 0 reader@ubuntu:~$ ! true reader@ubuntu:~$ echo $? 1
As you can see, the exclamation...