Reese Knowledgebase

Ternary Example

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 166
by: Reese K.
Posted: 07 May, 2015
Last updated: 07 May, 2015
Views: 590

Just a quick little example on ternary bash syntax.

[[ $member = *mongodbarb* ]] && port=30000 || port=27017

Example

reese@MacBook ~ $ node=webserver01
reese@MacBook ~ $ [[ $node = *webserver* ]] && port=30000 || port=27017
reese@MacBook ~ $ echo $port
30000
reese@MacBook ~ $ node=appserver01
reese@MacBook ~ $ [[ $node = *webserver* ]] && port=30000 || port=27017
reese@MacBook ~ $ echo $port
27017
This article was:   Helpful | Not Helpful
Prev   Next
How to redirect command line results into while loop     Puppet

RSS