Skip to main content
edited body
Source Link
john doe
  • 1k
  • 2
  • 18
  • 32

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=csvString=$($echoecho "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=($echo "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=$(echo "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

tabbing
Source Link
jesse_b
  • 41.6k
  • 14
  • 109
  • 163

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=($echo "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi   done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=($echo "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi   done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

I have an array of domains that I am attempting to iterate through and check if a string from a file matches any of the domains in the array. However, when the for loop starts, I get an error

line 64: www.google.com: syntax error: invalid arithmetic operator (error token is ".google.com") 

the array and for loop look like this:

sites=("www.google.com" "www.bing.com" "www.yahoo.com" "www.duckduckgo.com") while read line; do csvString=($echo "$line"); greppedDomain=$(echo "$line" | grep -Eo '[A-Za-z0-9]{2,62}\.[A-Za-z0-9]{2,62}\.[A-Za-z]{2,62}'); for i in "${sites[@]}"; do if [ "$greppedDomain" = "${sites[$i]}" ] then sitesOut+=($csvString); fi done done < sitelist.txt 

I am currently at a loss, maybe it is an issue with the way the grep output stores in the variable?

edited tags
Link
Jeff Schaller
  • 68.9k
  • 35
  • 122
  • 268
added 16 characters in body
Source Link
john doe
  • 1k
  • 2
  • 18
  • 32
Loading
added 4 characters in body
Source Link
user147505
user147505
Loading
added 2 characters in body
Source Link
john doe
  • 1k
  • 2
  • 18
  • 32
Loading
Fixed indentation
Source Link
jesse_b
  • 41.6k
  • 14
  • 109
  • 163
Loading
Source Link
john doe
  • 1k
  • 2
  • 18
  • 32
Loading