I do have a config file which has a structure like this:
username abc123
licensekey qwer1234
The file is located in $HOME/.test.config
.
Now I want to search for the keyword licensekey
and want to copy the following word qwer1234
as my key. If the word license key is not present or the file doesn't exist I want the user to add a license key manually and crate the file.
Do you have any suggestions? And did I made some mistakes in my code so far?
My code so far is:
keyfile='$HOME/.test.config'
if grep -q licensekey "$keyfile"; then
#what now?
else
while true; do
read -p "Whats your License Key? " key
key >> ${keyfile}
break
done
fi