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