Dave's Brain

Browse - Programming Tips - How should I declare a constant in bash?

Date: 2016nov7
Language: bash
OS: Linux

Q.  How should I declare a constant in bash?

A.  Use the readonly keyword.  But convention UPPERCASE is used:

readonly FILENAME='/etc/samba/smb.conf'
No spaces around the equals sign. I prefer single quotes for strings.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.