0

How to define a variable in a for..in loop

Example:

#!/bin/bash
api ="api keys"
for i in {1..305}; do
  wget "https://api.shodan.io/shodan/host/search?key=$api&query=&facets={facets}&page=$i"
done

But this gives an error of:

./script.sh: line 2: api: command not found
u-ways
  • 6,136
  • 5
  • 31
  • 47
SaN ThosH
  • 61
  • 5

1 Answers1

2

Bash variable declarations are space sensitive. So don't surround variable declarations with white space. Have a look at rule SC1068.

# Change:
api ="api keys" 
# To:
api="api keys"
u-ways
  • 6,136
  • 5
  • 31
  • 47