![컬 요청에 seq 및 xargs를 사용하는 방법](https://linux55.com/image/181688/%EC%BB%AC%20%EC%9A%94%EC%B2%AD%EC%97%90%20seq%20%EB%B0%8F%20xargs%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95.png)
curl
parms 값을 기반으로 작업을 수행하는 명령을 작업 중입니다.
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