linux – 如何在bash脚本的循环中使用参数运行curl命令?教程
参见英文答案 > Difference between single and double quotes in Bash 6个
我有一个curl命令,我想在for循环中执行.
例如,我想循环1-100次,当curl命令运行时,它在curl命令本身中使用iterator变量值.
就像是
#!/bin/bash
for i in {1..10}
do
curl -s -k 'GET' -H 'header info' -b 'stuff' 'http://example.com/id=$i'
done
--notice here I want var i to be changing with every curl.
一切都有帮助
谢谢.
解决方法:
试试这个:
set -B # enable brace expansion
for i in {1..10}; do
curl -s -k 'GET' -H 'header info' -b 'stuff' 'http://example.com/id='$i
done