Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions config_parser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

#key here is the first argument and we should trim white spaces

KEY=$(echo "$1" | tr -d '[:space:]')


#value is get from searching the file using the key

VALUE=$(grep -E "^$KEY=" "config.ini"| cut -d '=' -f 2)



#here we check if the value is empty ,then say it is error, else print the value

if [ -n "$VALUE" ]; then
echo "$KEY = $VALUE"
else
echo "Error: Key '$KEY' not present in the configuration file."
fi


#note : here i put the config.ini in the same directory of config_parser.sh