Reputation: 19388
Is this the recommended way of writing shell script?
#!/bin/bash
VAR_VERSION_NUMBER = "x.y"
cd /path/to/VAR_VERSION_NUMBER
Upvotes: 0
Views: 52
Reputation: 1581
No, this is correct way:
#!/bin/bash
VAR_VERSION_NUMBER="1.3"
cd /path/to/file/${VAR_VERSION_NUMBER}/more/path
The things missing from your example:
Also note that once the script is over and shell exits, you will be back to the original directory you started in. The effect of cd
command is limited to the shell you script is running in, not to the shell you are launching your script from.
Upvotes: 3