Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. rigstars2

    linux nested for loops HELP ..

    haha .. of course. I can't believe I missed that! I just kept staring at it for the longest time ..
  2. rigstars2

    linux nested for loops HELP ..

    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...
  3. rigstars2

    linux nested for loops HELP ..

    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...
  4. rigstars2

    linux nested for loops HELP ..

    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...
  5. rigstars2

    bash script bad substitution error message

    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...
  6. rigstars2

    shell Associate Array not printing out all elements

    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=(...
  7. rigstars2

    shell Associate Array not printing out all elements

    #!/opt/local/bin/bash THRESHOLD=0 SUBJECT_HOURLY="'Hourly'" SUBJECT_DAILY="'Daily'" DAILY=`df -h | grep -i "/Volumes/Daily" | awk '{print $5}' | sed "s/%//"` HOURLY=`df -h | grep -i "/Volumes/Hourly" | awk '{print $5}' | sed "s/%//"` declare -A MyArray MyArray=( [$HOURLY]=$SUBJECT_HOURLY...
  8. rigstars2

    bash for loop help - nested?

    feherke, Thanks for the help! i decided to get bash 4.4 installed and use your code...works great!
  9. rigstars2

    bash for loop help - nested?

    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...
  10. rigstars2

    bash for loop help - nested?

    totally forgot about associative arrays. I'll need to read up on it and I've never implemented it before. Thanks again feherke!
  11. rigstars2

    bash for loop help - nested?

    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...
  12. rigstars2

    comparing 2 arrays for invalid mac addresses only

    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
  13. rigstars2

    comparing 2 arrays for invalid mac addresses only

    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.
  14. rigstars2

    comparing 2 arrays for invalid mac addresses only

    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...
  15. rigstars2

    netstat foreign address code help?

    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...
  16. rigstars2

    rsync with hardlinks rotating snapshots code

    Thanks Sam. Appreciate your feedback. Very insightful. Always learning something new here.
  17. rigstars2

    rsync with hardlinks rotating snapshots code

    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?
  18. rigstars2

    rsync with hardlinks rotating snapshots code

    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...
  19. rigstars2

    rsync with hardlinks rotating snapshots code

    I’ll post the entire code when I get home tonight.
  20. rigstars2

    rsync with hardlinks rotating snapshots code

    additional info: this is after many runs of the script... please assist. much appreciated. sample expected ouput: hourly.0 10gb hourly.1 20k hourly.2. 20k hourly.3 10k hourly.4. 20k hourly.5 20k hourly.6 10k hourly.7. 20k hourly.8 20k hourly.9 20k hourly.10 20k hourly.11 20k unfortunate...

Part and Inventory Search

Back
Top