How can I use curl with a file descriptor for advanced data handling?

22 Replies, 2233 Views

For those who love one-liners, here’s a neat trick:

```bash
curl -d @<(grep "pattern" your_file.txt) http://example.com
```

This way, you can filter data on the fly and send it directly. No temp files needed!
If you’re dealing with binary data, curl using file descriptor is a lifesaver. Just make sure to use `--data-binary` instead of `-d` to avoid any encoding issues.

Example:
```bash
cat your_binary_file | curl -X POST --data-binary @- http://example.com
```

Works like a charm for me.



Users browsing this thread: 1 Guest(s)