Last active
April 26, 2017 19:54
-
-
Save ctrueden/ae0f024a0cdf2cb53c915d75b0759553 to your computer and use it in GitHub Desktop.
The joy of shell scripting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ if [ "condition" ]; then echo yes; else echo no; fi | |
yes | |
$ # Cool, but it's kind of verbose... is there a shorter way? | |
$ test "condition" && echo yes || echo no | |
yes | |
$ # Great! How succinct! | |
$ if [ "condition" ]; then cat nonexistentFile; else echo no; fi | |
cat: nonexistentFile: No such file or directory | |
$ # Aha, a non-zero exit code... | |
$ test "condition" && cat nonexistentFile || echo no | |
cat: nonexistentFile: No such file or directory | |
no | |
$ # Oh noez!!!!!!!!!!!!1111one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment