#!/bin/bash
if [ -z "$BASH_VERSION" ]; then exec bash "$0" "$@"; exit; fi

before_ip=$1
after_ip=$2
grep_path=$3

if [[ $before_ip == '' || $after_ip == '' ]]; then
		echo '[Usage] $0 {before_ip} {after_ip}'
		exit
fi

grep -rn ${before_ip} ${grep_path} | awk -F':' {'print $1'} | uniq | /usr/bin/xargs sed -i "s/${before_ip}/${after_ip}/g"

echo "success"