Post History
An exclamation mark followed by space in the beginning of a pipeline will negate the final exit code of the pipeline. Here's an example in Bash. Echoing $? will print out the exit code of the prev...
Answer
#2: Post edited
An exclamation mark followed by a space in the beginning of a pipeline will negate _the final exit code_ of the pipeline.- Here's an example in Bash. Echoing `$?` will print out the exit code of the previous command (which is also an echo in this case).
- ```bash
- $ echo OpenStreetMap is the best map
- OpenStreetMap is the best map
- $ echo $?
- 0
- $ ! echo OpenStreetMap is meh
- OpenStreetMap is meh
- $ echo $?
- 1
- ```
- This is a [Posix thing](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_02).
- An exclamation mark followed by space in the beginning of a pipeline will negate _the final exit code_ of the pipeline.
- Here's an example in Bash. Echoing `$?` will print out the exit code of the previous command (which is also an echo in this case).
- ```bash
- $ echo OpenStreetMap is the best map
- OpenStreetMap is the best map
- $ echo $?
- 0
- $ ! echo OpenStreetMap is meh
- OpenStreetMap is meh
- $ echo $?
- 1
- ```
- This is a [Posix thing](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_02).
#1: Initial revision
An exclamation mark followed by a space in the beginning of a pipeline will negate _the final exit code_ of the pipeline. Here's an example in Bash. Echoing `$?` will print out the exit code of the previous command (which is also an echo in this case). ```bash $ echo OpenStreetMap is the best map OpenStreetMap is the best map $ echo $? 0 $ ! echo OpenStreetMap is meh OpenStreetMap is meh $ echo $? 1 ``` This is a [Posix thing](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_02).