So, I have an array of IP's, and an Array of Dates... Both Arrays are the same length So, DATE[0] is the date that IP[0] was assigned...
I'm trying to parse through an entire month of logs and change the IP when it hits a certain date... I know this isn't right, so please help with my code: (the Grep statements DO work, are from other code, basically just need to change SEARCHPATH depending on the date check....)
ARRAY_COUNTER=0
NEW_GREP_TERM=${IPS[0]}
for i in {01..31}
do
SEARCHPATH=${BASEPATH}/${DEF_YEAR}${DEF_MONTH}/SG_22[8-9]${DEF_MONTH}${i}*
zgrep --no-filename $NEW_GREP_TERM $SEARCHPATH | awk -f /usr/local/bin/cvsit.awk >> $OUTFILE
if [$i = ${DATES[$ARRAY_COUNTER]}]
then
NEW_GREP_TERM = ${IPS[$ARRAY_COUNTER]}
zgrep --no-filename $NEW_GREP_TERM $SEARCHPATH | awk -f /usr/local/bin/cvsit.awk >> $OUTFILE
ARRAY_COUNTER=$ARRAY_COUNTER+1
fi
done
[
(and the[
command expects its last argument to be]
, complaining if it is not).bash
, it's better to use[[
and]]
, which is smarter but less portable. You'll have fewer syntax errors, and less confusing behavior that way.let ARRAY_COUNTER=$ARRAY_COUNTER+1
or((ARRAY_COUNTER++))