Created
October 23, 2011 07:28
-
-
Save tian-im/1306994 to your computer and use it in GitHub Desktop.
Shell script programming practices
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 else then in one line | |
[ $condition ] && echo 'true' || echo 'false' | |
# if argument empty then | |
local arg | |
echo ${arg:-default_value} # => default_value | |
arg=present | |
echo ${arg:-default_value} # => present | |
# if argument not empty then replace the text | |
# note that no regular expression could be applied | |
echo ${arg//t/t?} # => present? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment