参见英文答案 > 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

见:Difference between single and double quotes in Bash

标签: bash, linux, curl, scripting

相关文章推荐

添加新评论,含*的栏目为必填