Vehicle: BMW Class
checkin_note:
Tyre : Four
path_id : 11
vault_file_size: -1
Vehicle: Toyota Class
checkin_note:
Tyre : Four
path_id : 11
vault_file_size: -1
Vehicle: Chevrolet Class
checkin_note:
Tyre : Five
path_id : 11
vault_file_size: -1
If Tyre = Four then Print Vehicle i.e. BMW/Chevrolet/Toyota
FilePath="test_result.txt"
# read line by line
# temporarily add a : to the IFS (whitespace) and split on it
while IFS=":$IFS" read key val junk
do
case $key in
("Vehicle")
vehicle=$val
;;
("Tyre")
if [ "$val" = "Four" ]
then
echo "$vehicle"
fi
;;
esac
done < "$FilePath"