Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- source Configuration.conf
- echo $Name
- echo $Age
- echo $Address
- source Configuration.conf
- while [ $1 ] // Here 1 is representing the first Key of the configuration file.
- do
- //My Logics
- done
- configfile=./Configuration.conf
- . "$configfile"
- declare -A configlist
- while IFS='=' read -r key val ; do
- # skip empty / commented lines and obviously invalid input
- [[ $key =~ ^[[:space:]]*[_[:alpha:]] ]] || continue
- # Stripping up to the last space in $key removes "export".
- # Using eval to approximate the shell's handling of lines like this:
- # var="some thing with spaces" # and a trailing comment.
- eval "configlist[${key##* }]=$val"
- done < "$configfile"
- # The keys are "${!configlist[@]}", the values are "${configlist[@]}"
- #
- #for key in "${!configlist[@]}" ; do
- # printf '"%s" = "%s"n' "$key" "${configlist[$key]}"
- #done
- for value in "${configlist[@]}" ; do
- : your logic goes here
- done
- keys=( $(grep -oP 'w+(?==)' conf.conf) )
- for (( i=0; i < ${#keys[@]}; i++ )); do
- printf "%dt%sn" $i "${keys[i]}"
- done
- echo
- source conf.conf
- for var in "${keys[@]}"; do
- printf "%st=> %sn" "$var" "${!var}"
- done
- 0 Name
- 1 Age
- 2 Address
- Name => name_value
- Age => age_value
- Address => addr_value
- sed -n 's/export//p' conf.sh | while read expression ; do
- key=$(cut -d= -f1 <<< "$expression")
- value=$(cut -d= -f2 <<< "$expression")
- # your logic comes here ...
- echo "$key -> $value"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement