1#!/bin/bash 2 3# This program will modify a file by substituting all instances of a specified 4# IP with "DUMMYIP". This is useful for making the IP address generic and thus 5# searchable. 6 7# Description of argument(s): 8# ip_addr An IP address. 9# file_path The path to a file which is to be modified. 10 11# Get arguments. 12ip_addr="${1}" ; shift 13file_path="${1}" ; shift 14 15# Validate arguments. 16if [ -z "${ip_addr}" ] ; then 17 echo "**ERROR** You must provide an IP address as the first positional" \ 18 "parameter." >&2 19 exit 1 20fi 21 22if [ -z "${file_path}" ] ; then 23 echo "**ERROR** You must provide a file path as the second positional" \ 24 "parameter." >&2 25 exit 1 26fi 27 28ip_addr_regex=`echo ${ip_addr} | sed 's/\(\.\)/\\\./g'` 29sed -i 's/'${ip_addr_regex}'/DUMMYIP/g' ${file_path} 30