curlリクエストにseqとxargsを使用する方法

curlリクエストにseqとxargsを使用する方法

curlparms 値に基づいて操作を実行するコマンドを処理しています。

curl 'http://www.example.com/actionid?id=123'

id動的に値をポンピングしたいです。

seq 1 10 | xargs -I + curl 'http://example.com/actionid?id=123'

私が得る出力から

curl 'http://example.com/actionid?id=+'

curl 'http://example.com/actionid?id=+'

curl 'http://example.com/actionid?id=+'
....

私が試した値にどのように渡すことができますか?

seq 1 10 | xargs -I + curl 'http://example.com/actionid?id=123'`< <(printf '+\n' $(seq 1 10)

私は同じ結果を得ます。

解決策

それを囲む'-'~'私は今働いています。

答え1

printf '%d\n' {1..10} | xargs -i -- echo curl http://example.com/actionid?id={}

時間を削除しechoて実際のURLを入力してください。

答え2

ループを使用してください。

for i in $(seq 1 10) ; do
    curl http://example.com/actionid\?id=$i
done

関連情報