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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -