Luckily, your input file has a format the shell understands when it comes to
assigning variables a value:
var1=value1 var2=value2 etc. So we can simply
read each line and use the
eval command to evaluate the line.
Put the following into a file, say
chmod +x parse.sh and
run it with your input file as a parameter.
while read line; do
done < "$1"
name=Joan age=42 ip=172.20.1.80 sex=M loc=UK
loc=IR sex=F ip=172.20.1.1 age=32 name=Sandra
me@ubuntu:~> ./parse.sh input.txt
Please note that the values must not have a space in them. E.g.
ip=... name=Ubai salih loc=...
would not work and give syntax errors. Also, if the input file would contain a line with a
bad_command that command gets executed because that is how
eval works: it just executes the given string.