Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ScalaWilliam/f882c6dcaebee19a7b6f6bdbbb74d676 to your computer and use it in GitHub Desktop.
Save ScalaWilliam/f882c6dcaebee19a7b6f6bdbbb74d676 to your computer and use it in GitHub Desktop.
Expanding params for curl... cool.
```
[03:18] <ScaWilliam> I have a file that contains multiple lines of curl arguments, eg one line -X POST, one line -H 'Content-Type: application/json' one line -d '{"some": "payload"}' --- I tried doing curl "$(cat file.txt)" http://host/ but it won't work - it doesn't evaluate the arguments properly. How do I do what I want?
[03:20] <greycat> ScaWilliam: mapfile -t curlargs < myfile; curl "${curlargs[@]}" "$url"
[03:30] <ScaWilliam> @greycat your command worked with one line -X, another POST, another -H another Content-Type: ...
[03:31] <greycat> But...?
[03:31] * greycat waits for "I actually have multiple options per line and they're shell-quoted"
[03:31] <ScaWilliam> hah no, figured out that one myself.
[03:31] <ScaWilliam> thanks, I'll share your website on twitter, this was very helpful :-)
lsof -n | awk '{print $2}'|sort|uniq -c|awk '{print $1,$2}'|sort -k 1n|tail
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment