Thanks! Works almost perfectly except for i < ${#country[i]}; For whatever reason I can't think of, the code won't print anymore elements beyond 4th index value so, I had to replace the array length with an integer value i < 18 for it work with more elements.
argentina 1701
brazil...
The ~/files/zones.txt just contains the initials of the countries
ar
br
cz
# below are 3 the $init.zone files which are just IPs contents
# ar.zone
27.2.0.0/15
27.64.0.0/12
27.118.16.0/20
# br.zone
45.164.228.0/22
45.165.36.0/22
45.165.44.0/22
45.165.112.0/22
# cn.zone
27.126.152.0/22...
Hello all,
Need some help here ..
country=(argentina brazil china)
for (( i=0; i < ${#country[i]}; i++ )); do
for init in $(cat ~/files/zones.txt); do
echo ${country[i]} `cat ~/lists/$init.zone| wc -l`
done
done
#desired output
argentina 2000
brazil 400
china 5000
#wrong output I...
Each item in the list is an associated array. I'm trying to traverse each key/value from each associated array. Error message I get ... ${!$x[@]}: bad substitution
I tried substituting with backticks and quotations ..
aaList=( aa1 aa2 aa3 )
for x in "${aaList[@]}"
do
for KEY in...
feherke,
You are right on! The keys cannot be the same but the values can be. Just re-arranged MyArray and works great now! Appreciate the assist!
#!/bin/bash
SUBJECT_HOURLY="Disk 'Hourly'"
SUBJECT_DAILY="Disk 'Daily'"
DAILY_VALUE="2"
HOURLY_VALUE="2"
declare -A MyArray
MyArray=(...
feherke,
I tried running your code but I get ..i'm running this on a mac ..minor changes due to bash version too..
./test2.sh: line 13: /india.zone: No such file or directory
TABLES="/Users/rigs/tables"
declare -a initial=( ['br']='brazil' ['cn']='china' ['in']='india' )
for country in...
I'm trying to create a loop or I believe in this case nested for loops but the logic escapes me.
Can someone please assist here? My logic looks way off here ..
for ip in $(cat $ZONES_PATH/br.zone ); do ipset -A brazil $ip; done
for ip in $(cat $ZONES_PATH/cn.zone ); do ipset -A china $ip; done...
I think this will do ..thanks for the help Salem!
var=$(comm -1 -3 <(sort ~/valid.txt) <(sort ~/invalid.txt))
for ((i = 0; i < ${#var[@]}; i++)); do
echo "${var[i]}" > ~/invalid_macs.txt
done
Salem,
Wow, I appreciate this but I'm introducing folks bash scripts not perl. We'd like to be at level at some point. Can you provide a bash script version instead please? Thanks in advance.
I have 2 arrays and I want to compare and only print the non-valid macs in red/bold. The valid macs array will always be constant. I tried comparing 1 element at a time but doesn't work as it would still pick up valid array elements. Any help would be appreciated.
valid macs
90:40:95:29:C4:81...
I'm trying to massage code so that if it finds any ip address(except 0.0.0.0) in the foreign address column it will print out "foreign address found"
right now, it is printing "foreign address found" due to $5 being a column ..
the default ip in column $5 is 0.0.0.0:*
if there is an easier...
And in response to your question, yes, the hourly.0 moves to hourly.1 moving the first time full backup down the line until it gets to hourly.11 and then it gets deleted per the code. it should repeat again ..with full backup starting at hourly.0, am I right?
Here is the code. If you run it, you'll need a partition/volume called 'Hourly' ...
It appears to be working. Just need a second opinion on it ..because it shouldn't be creating more than 1 full backup other than the first time it runs and excluding the SRC directory. After running it more than...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.