Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy are these IF statement not working?
    primarykey
    data
    text
    <p>I have two IF Statements that should be 'Hitting/Triggering', but something isn't kosher in my code. I'm just learning BASH, and appreciate any help. </p> <p>I have two arrays created, earlier in code,</p> <pre><code>#Array of Dates DATES=($(awk -F'/' '{print $2}' "${TEMPFILE}")) #Array of IP's IPS=($(awk '{print $2}' "${TEMPFILE}")) </code></pre> <p>Since they are created from the same file, they have the same length.</p> <p>Example of two arrays: </p> <pre><code>01 06 07 08 11 23 24 192.168.0.4 192.168.0.6 192.168.0.4 192.168.0.5 192.168.0.6 192.168.0.4 192.168.0.5 </code></pre> <p>In my statement i am parsing through a Bluecoat log, and the IF statements will check to see if the IP has changed from the arrays (formed from a DHCP log parsing). <strong>Everything seems to work (seeing results in output) except that the IF statements aren't being triggered, so the IP never changes.</strong> </p> <p>Here is my code for searching an entire month( a day at a time)</p> <pre><code>ARRAY_COUNTER=1 NEW_GREP_TERM=${IPS[0]} for i in {01..31} do SEARCHPATH=${BASEPATH}/${DEF_YEAR}${DEF_MONTH}/SG_OIG__22[8-9]${DEF_MONTH}${i}* zgrep --no-filename $NEW_GREP_TERM $SEARCHPATH | awk -f /usr/local/bin/cvsit.awk &gt;&gt; $OUTFILE if [[ "${i}" == "${DATES[$ARRAY_COUNTER]}" ]]; then if [[ "${IPS[$ARRAY_COUNTER]}" != "${IPS[$ARRAY_COUNTER-1]}" ]]; then echo -e "Change IP" NEW_GREP_TERM=${IPS[$ARRAY_COUNTER]} zgrep --no-filename $NEW_GREP_TERM $SEARCHPATH | awk -f /usr/local/bin/cvsit.awk &gt;&gt; $OUTFILE fi ARRAY_COUNTER++ fi done </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload