What command means "do nothing" in a conditional in BASH? -


sometimes when making conditionals, need code nothing, e.g., here, want bash nothing when $a greater "10", print "1" if $a less "5", otherwise, print "2":

if [ "$a" -ge 10 ] elif [ "$a" -le 5 ]     echo "1" else     echo "2" fi 

this makes error though. there command nothing , not slow down script?

the no-op command in shell : (colon).

if [ "$a" -ge 10 ]     : elif [ "$a" -le 5 ]     echo "1" else     echo "2" fi 

from bash manual:

: (a colon)
nothing beyond expanding arguments , performing redirections. return status zero.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -