bash에 for each 문을 curl과 결합할 수 있다. 


for i in {1..10}; do

  curl -X GET "http://localhost/api/v1/orders/$1" -H "accept: application/json;charset=UTF-8"

done



수 천개의 파일에 매개 변수를 넣어 확인하려면 {1..10} 대신 $(cat file)으로 변경만 하면 된다.


for i in $(cat file); do

  curl -X GET "http://localhost/api/v1/orders/$i" -H "accept: application/json;charset=UTF-8" 

  sleep 1

done



비슷한 사례로서, host 장비의 ip를 얻고 싶다면 다음 코드를 사용한다. 



for i in $(cat hosts); do

   ping -c1 $i | grep bytes | grep PING | awk {'print $2 substr($3, 1, length($3)-1)'}
   sleep 1

done





Posted by '김용환'
,