Unix variables - The correct way -


is recommended way of writing shell script?

#!/bin/bash var_version_number = "x.y" cd /path/to/var_version_number 

no, correct way:

#!/bin/bash  var_version_number="1.3" cd /path/to/file/${var_version_number}/more/path 

the things missing example:

  1. dollar sign ($) in front of variable name (var_version_number).
  2. there should no space between variable name , equal sign (=) in assignment.
  3. it practice surround variable name in curly braces, not needed here.

also note once script on , shell exits, original directory started in. effect of cd command limited shell script running in, not shell launching script from.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -