Skip to content

Commit 5445916

Browse files
committed
Add Run A cURL Command Without The Progress Meter as a Unix TIL
1 parent ccc0475 commit 5445916

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1320 TILs and counting..._
13+
_1321 TILs and counting..._
1414

1515
---
1616

@@ -1316,6 +1316,7 @@ _1320 TILs and counting..._
13161316
- [Repeat Yourself](unix/repeat-yourself.md)
13171317
- [Replace Pattern Across Many Files In A Project](unix/replace-pattern-across-many-files-in-a-project.md)
13181318
- [Run A Command Repeatedly Several Times](unix/run-a-command-repeatedly-several-times.md)
1319+
- [Run A cURL Command Without The Progress Meter](unix/run-a-curl-command-without-the-progress-meter.md)
13191320
- [Safely Edit The Sudoers File With Vim](unix/safely-edit-the-sudoers-file-with-vim.md)
13201321
- [Saying Yes](unix/saying-yes.md)
13211322
- [Search Files Specific To A Language](unix/search-files-specific-to-a-language.md)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Run A cURL Command Without The Progress Meter
2+
3+
By default when you run a `curl` command that will output to the terminal, it
4+
disables the progress meter for the request. When the response output is
5+
redirected or piped somewhere else however, the progress meter will be
6+
displayed in the terminal.
7+
8+
```bash
9+
$ curl -H "Content-Type: application/json" -G http://myurl.com | jq
10+
% Total % Received % Xferd Average Speed Time Time Time Current
11+
Dload Upload Total Spent Left Speed
12+
100 2515 0 2515 0 0 4184 0 --:--:-- --:--:-- --:--:-- 4184
13+
```
14+
15+
This can be disabled with the `-s` flag (which is short for `--silent`).
16+
17+
```bash
18+
$ curl -s -H "Content-Type: application/json" -G http://myurl.com | jq
19+
```
20+
21+
However, the `-s` flag will also suppress error messages. This is a bit
22+
unhelpful. You can then add in the `-S` flag (short for `--show-error`) to
23+
ensure that error messages are shown even while the progress meter is
24+
suppressed.
25+
26+
```bash
27+
$ curl -sS -H "Content-Type: application/json" -G http://myurl.com | jq
28+
```
29+
30+
See `man curl` for more details.

0 commit comments

Comments
 (0)