An open API service indexing awesome lists of open source software.

https://github.com/dotupnet/dotupbashsettings

Load and save configuration files from bash scripts
https://github.com/dotupnet/dotupbashsettings

bash bash-script configuration configuration-files ini linux settings settings-files

Last synced: 4 months ago
JSON representation

Load and save configuration files from bash scripts

Awesome Lists containing this project

README

          

# DotupBashSettings
Load and save configuration files from bash scripts

Install the script:
```bash
bash <(curl -s https://raw.githubusercontent.com/dotupNET/DotupBashSettings/master/install.sh)
```

Functions:
- **Bash-LoadSettings** *configFile* *configArray*
- **Bash-SaveSettings** *configFile* *configArray*
- **Bash-GetSettings** *configFile* *key*
- **Bash-SetSettings** *configFile* *key* *value*
- **Bash-PrintSettings** *configArray*

```bash

. path-to-file/BashSettings.sh

# Initialize array that holds the configuration
typeset -A config

# Load complete configuration file into variable
Bash-LoadSettings "$(pwd)/.config" config

# Print key value pairs
Bash-PrintSettings config

# Modify entry by key
config[AUTO]=9

# Print key value pairs
Bash-PrintSettings config

# Save complete configuration to file
Bash-SaveSettings "$(pwd)/.config.saved" config

# Accesss value by key
echo ${config[AUTO]}

# Accesss value by key from file
autoValue=$(Bash-GetSettings "$(pwd)/.config.saved" "AUTO")
echo "AUTO value: $autoValue"

# Write value by key to file
Bash-SetSettings "$(pwd)/.config.saved" "AUTO" 99

```