With this InFile ...
Code:
192.168.1.168 abdulatif
192.168.1.64 amr
192.168.1.98 amr
192.168.1.34 ayoup
192.168.1.35 eshal
192.168.1.21 farma
192.168.1.191 hanan
192.168.1.125 hane
192.168.1.30 hane
192.168.1.249 majde
192.168.1.40 malbak
192.168.1.227 mjut
192.168.1.117 oct
... this code ...
Code:
awk '{a[$2]=a[$2]" "$1" &"}
END{for (j in a) if (length(a[j])>20) print j,"use"a[j]}' $InFile \
|sed 's/ &$//' \
|sort \
|paste -sd\| \
|sed 's/|/ || /g' \
>$OutFile
... produced this OutFile ...
Code:
amr use 192.168.1.64 & 192.168.1.98 || hane use 192.168.1.125 & 192.168.1.30
Daniel B. Martin