Skip to content

Shell script is used to read property value from a file easily

Notifications You must be signed in to change notification settings

chungxon/load_properties

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Load Properties Script

This helpful script is used to read properties from a file for use in another script

Usage

1. loadProperties function

  • Call the function with the properties file and an optional prefix to load all properties into variables

  • The prefix will be prepended to all variable names to avoid naming conflicts

    loadProperties <file> [prefix]
  • Example usage: loadProperties examples/example.properties "app_"

  • Example accessing the properties: echo "App Name: $app_appName"

2. getProperty function

  • Call the function with the properties file and property key to get a single property value

  • Optional parameters for separator (default "=") and whether to trim whitespace (default false)

    getProperty <file> <key> [separator] [trim_value]
  • Example usage: appName=$(getProperty examples/example.properties appName)

  • Example with options: value=$(getProperty config.ini key ":" true)

Demo

image

About

Shell script is used to read property value from a file easily

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages