如何在for..in循环中定义变量
示例:
#!/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
但这会导致以下错误:
./script.sh: line 2: api: command not found
答案 0 :(得分:2)
Bash变量声明是空间敏感的。因此,请勿在变量声明中加上空格。看看rule SC1068。
# Change:
api ="api keys"
# To:
api="api keys"