A new functionality has recently been added to bash-related comma utilities that allows specifying default values of command line options where the options are defined.
The following code uses command line option --filename. The script defines a bash variable called filename, whose value is specified by the option on the command line. However, if the option is not given on the command line, the default value will be used.
Save the code above in a file called script and make it runnable with 'chmod +x ./script'. Then execute the following commands:
The first command uses the default value (example.txt), while the second command uses the given value (another.txt).
The default values can be enclosed in double or single quotes if necessary. For instance: