using awk or sed need help

Hi experts,

I have a file with the following output

 HOST = host1
SERVICE_NAME = service1
HOST = host2
SERVICE_NAME = service2
HOST = host3
SERVICE_NAME = service3

Need the output like this

host1;service1
host2;service2
host3;service3

I tried with awk or sed but I am not getting the required output need your expertise for the same
:wall:

#!/bin/bash

while read name op value
do
         case $name in
                  HOST) echo -n "$value;" ;;
                  SERVICE_NAME) echo "$value" ;;
  esac
done
nawk '$1=="HOST"{h=$NF;next}{print h,$NF}' OFS=';' myFile
1 Like