curl
नेटवर्क
इस्तेमाल
curl [options] <url>किसी URL को लाकर उसका मुख्य भाग टर्मिनल पर छापता है; ब्राउज़र के उलट यह `-L` के बिना रीडायरेक्ट का पीछा नहीं करता, इसलिए 301 आने पर खाली उत्तर जैसा लगता है।
आम विकल्प
| विकल्प | अर्थ |
|---|---|
| -L | Follow redirects. curl does not follow them on its own, unlike a browser. |
| -i | Print the response headers along with the body; -I sends HEAD and prints headers only. |
| -d '{"a":1}' | Send a request body. This alone already means POST. |
| -H "Content-Type: application/json" | Add a request header; repeat -H for more. |
| -X PUT | Override the method. Unnecessary with -d, which is already a POST. |
| -o <file> / -O | Save the body to a file / save it under the remote filename. |
| -s / -sS | No progress meter / silent but still print errors. |
| -f | Exit nonzero on HTTP 4xx and 5xx instead of printing the error page. |
| -k | Skip certificate verification. Debugging only, never in production. |
उदाहरण
curl -fsSL https://example.com/install.sh -o install.shDownload quietly, follow redirects, fail loudly on a 404.
curl -i -H "Content-Type: application/json" -d '{"name":"a"}' https://api.example.com/itemsPOST JSON and read the response headers.
curl -s -o /dev/null -w "%{http_code}\n" https://example.comPrint just the status code.
कनेक्शन न बने तो ये बताते हैं कि बात कहाँ तक पहुँची — नाम हल नहीं हुआ, रास्ता नहीं, या पोर्ट बंद है।
कैसे पढ़ें
- बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
- तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
- विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।
आम सवाल
Q. curl क्या करता है?
किसी URL को लाकर उसका मुख्य भाग टर्मिनल पर छापता है; ब्राउज़र के उलट यह `-L` के बिना रीडायरेक्ट का पीछा नहीं करता, इसलिए 301 आने पर खाली उत्तर जैसा लगता है।
Q. इसे कैसे लिखें?
curl [options] <url> — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।
Q. कितने विकल्प जानने लायक़ हैं?
यहाँ 9 दिए हैं; पूरी सूची man curl में है। यह कमांड नेटवर्क में आती है।
मिलती-जुलती कमांड
man पेज: man curl