LNA LNA - 29 days ago 20
SQL Question

Repetitive CURL commands via the terminal

I have a list of 3000 unique IDs.

I want to run multiple CURL commands, like so:

$ curl -i -u user:password -X DELETE https://mywebsite.com/rest/v2/page/[UniqueID]/
$ curl -i -u user:password -X DELETE https://mywebsite.com/rest/v2/page/[UniqueID]/
$ curl -i -u user:password -X DELETE https://mywebsite.com/rest/v2/page/[UniqueID]/


etc.

Is there a way to do this non-manually, so that I'm not copying/pasting in each unique ID and pressing return on my mac terminal 3000 times?

Answer

You can use the bash brace expansion http://wiki.bash-hackers.org/syntax/expansion/brace

For example id 1,2,3,4

curl -i -u user:password -X DELETE https://mywebsite.com/rest/v2/page/{1,2,3,4}/

or id 1 up to 100

curl -i -u user:password -X DELETE https://mywebsite.com/rest/v2/page/{1..100}/
Comments