LNA
LNA

Reputation: 1447

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?

Upvotes: 0

Views: 199

Answers (1)

madnight
madnight

Reputation: 418

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}/

Upvotes: 1

Related Questions