Reputation: 51
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
Upvotes: 0
Views: 276
Reputation: 5787
[
and ]
should have leading and post blank(s). You can run which [
to know that the [
is actually a command. The if
keyword accepts the boolean statement or variable, and the [ foo ]
is to test the foo
to be true or false.0, 1, 2, 3, ..., 31
, you can use $(seq 0 31)
in BASH. EDIT: The leading 0
is important here. Thus the {...}
built-in notation is more preferable.Upvotes: 1