Good afternoon, I'm trying to figure out why my variable loop is only using the last line in my do loop to write data my ISLAND loop is finding city names and assigning a static variable (ISLAND-X-XO)
IFS=$'\n'
OUTPUTDIR='/home/IMPACT_COUNT'
for CSR in `ls -1 configs/ | egrep 'router{1-5]'`
do
ISLAND=$(echo $CSR | grep -q "tampa" && echo ISLAND-TAM-MCR-XO) <- does not write
ISLAND=$(echo $CSR | egrep -q "washington-dc|ashburn" && echo ISLAND-WDC-XO) <- writes
COUNT=$(grep "up up" /otherconfigs/$CSR | wc -l)
echo $CSR $COUNT >> $OUTPUTDIR/$ISLAND
done
Each one of the "ISLAND" lookups works individually, just not stacked.
Tried [if then] options Expecting multiple lookups in the loop to write to the DIR
#!/bin/bash) to your script, then paste it at shellcheck.net and try to implement the recommendations made there.