Artificial intelligent assistant

need help script I am trying to solve this problem for a long time.Please show me the light. file1.txt Alya Grant cat dog Ava dog tiger snake Samia bus train car plane I need output result is like this. Alya Grant cat dog Alya Grant=2 Ava dog tiger snake Ava=3 Samia bus train car plane Samia=4 (or) like this Alya Grant=2 Ava=3 Samia=4

Assuming `/path/to/input-file` contains the list you mentioned in your post, we could use:


awk 'BEG{name="";count=0}{if ($0 == "") { print name "=" count; name = ""; count=0; } else { if (name == "") { name = $0; } else {count = count + 1} }}END{print name "=" count;}' /path/to/input-file
Alya Grant=2
Ava=3
Samia=4

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 24b2b87b7603a3d1a8cdd912c2fba818