#!/bin/bash oldIPList='192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.5' newIPList='192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5' for oldip in $oldIPList && newip in $newIPList do echo "$oldip $newip" done