2026-05-25

cURL 小技巧:不輸出 response body

方法有兩種

方法有兩種

使用 output,輸出至「空裝置」

例如 linux 就是輸出至 /dev/null,見下:

$ # linux 
$ curl https://example.org -o /dev/null
C:\> REM Windows 命令提示字元
C:\> curl https://example.org -o nul
PS C:\> # Powershell
PS C:\> curl https://example.org -o $null

使用 --out-null 參數

這方法得 cURL v8.16.0. 才能使用。要檢查版本可使用 curl --version 。例如:

curl https://example.org --out-null

參考資料

Stenberg, D. (n.d.). Curl Man Page. Curl. https://curl.se/docs/manpage.html

沒有留言:

張貼留言